Solved

defining wether a field is shown when using a certain search category in cdml

Posted on 2003-11-17
6
333 Views
Last Modified: 2010-04-27
hello i have a website running from a filemaker database with a search page in cdml.  I would like to specify a field to appear only when a certain search option is used (a drop down list with categories) otherwise if the user searches by date, etc this field should not appear
can this be done???
thanks in advance

benjamin martin
benjiart@wanadoo.fr
0
Comment
Question by:benjiart
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Mariano_Peterson
Comment Utility
I'm not sure I understand exactly what you want to do.

If you want the return page (-format=...) to display HTML based on the values from the last form submission, I don't think this can be done in CDML.  You'd have to use a regular web scripting language like Lasso, PHP, ASP, etc.  You can use the FX class (free at www.iviking.org) to connect PHP and FileMaker.  With PHP you could use something like the following to determine if a list value was selected:

<?
if ($_REQUEST[myList]  != "") {
   print "<input type=text ...>"
}
?>


If instead you want a field to dynamically appear and disappear on the search page based on the selection from a list, you need to use JavaScript.  Here is an example:

<html>
<head>
<script language="Javascript">
function objectChange(thisObject, thatObject) {

      // Check for invalid object references
      if (!thisObject || !thatObject) {return false;}
      
      // Get the selected value
      // (currently only works with single selection lists and text fields)
      if (thisObject.type == "select-one") {
            listIndex = thisObject.selectedIndex;
            var value = thisObject.options[listIndex].value; // you can also use .text
      } else if (thisObject.type == "text") {
            var value = thisObject.value;
      }

      // Show or hide the hidden field
      if (value == "Dell"){
            showElement(thatObject.name);
      } else {
            hideElement(thatObject.name);
      }
      return true;
}

function showElement(elem) {
      if (!elem) {return false;}      // check for invalid object reference
      document.getElementById(elem).style.visibility='visible';
      return true;
}

function hideElement(elem) {
      if (!elem) {return false;} // check for invalid object reference
      document.getElementById(elem).style.visibility='hidden';
      return true;
}
</script>
</head>

<body>
<form name="form">
<table>
<tr>
      <td>
            Select one:&nbsp;
            <select name="myList" onChange="objectChange(this, this.form.myHiddenField)" style="width: 150px;">
                  <option value="Apple">Apple</option>
                  <option value="Dell">Dell</option>
                  <option value="HP">HP</option>
                  <option value="IBM">IBM</option>
                  <option value="Sun">Sun</option>                  
            </select>
      </td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
      <td>The hidden field is below.<br>
      Select Dell to show the field.<br>
      Select anything else to hide it.<br><br>
      ( I'm not sure if this works with Netscape )<br></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
      <td><input type="text" name="myHiddenField" value="" style="visibility: hidden;"></td>
</tr>
</table>
</form>
</body>

</html>
0
 
LVL 28

Expert Comment

by:lesouef
Comment Utility
I have no idea about doing this in CDML (I don't use it), but this can be done at Fmaker level.
Create a calculated field of which the value will be true only when a certain search mode is true.
Create a global field for the search mode, and another field for the data to be shown:
Example:
- field to appear or not = data_shown
- field containing real data = data (already existing)
- search mode = smode (global)
data_shown = if (search_mode = "yes or whatever" ; data ; "")
Assuming you can set the search mode from the web page, data_shown will always be visible, but it will be empty. Is that enough?
0
 

Author Comment

by:benjiart
Comment Utility
i think i didnt explain the situation very well, im really new to filemaker it would be great if there is a  possible solution directly in filemaker, ;-))  
I am building a website to search a filemaker database using cdml
The index.html is a search page with different options, date, record number, and a value list menu which pulls down were you can chose
a category. the category list is generated by FMP-ValueListItem
from a field in my database, if a user uses this search option the results.html page loads an extra  field "introtext" from the database  ,  
ideally it would be even better is this "introtext" field  would load as introtext.html with a button which would go to a page, results.html which would contain the results for the category chosen on the index.html   i hope some of this is clear, ;-)) thanks again and in advance for your help

benjamin
0
 
LVL 3

Accepted Solution

by:
Mariano_Peterson earned 500 total points
Comment Utility
See my response to your previous post (http://www.experts-exchange.com/Databases/FileMaker/Q_20800329.html).  Here is some JavaScript that will dynamically choose a response page based on what the user enters on the search page.  This JavaScript code goes on the search page.  

You can cut and paste the code below and save it as an html file.  Then you can open the html file from your desktop and see how the response file (-format=...) is changed depending upon what you've entered in the form.

In this example, the determination of which response page to use is made on the client side.  It would be much better if that were determination were made on the server side, when it receives the form submission.  Unfortunately, CDML has extremely limited methods for handling web requests (form submissions).  If you were to use a regular web programming language (like PHP) this could be very easily handled on the server side (much more easily and with less code, too).

If you're just starting with CDML, then I recommend you ditch it in favor of PHP.  PHP is free and much more powerful.  There is more to learn with PHP - BUT, I believe its easier because if you have a task to accomplish there is almost always a straight forward way to do it.  With CDML you can rarely perform normal tasks (like your request above) without having to spend lots of time thinking up fragile ways to work around the severe limitations of CDML.  I used CDML before I learned PHP, and I wish I had not wasted my time with CDML and instead just learned PHP right off the bat.  I would have saved soooo much time.  I'm just trying to pass this discovery on to you.


-- note --
this is a direct copy of my code at the top of your other post at:
http://www.experts-exchange.com/Databases/FileMaker/Q_20800329.html

______________________________________________________________

<html>
<head>
<script language="JavaScript">
function dynamicSubmit (myForm) {

     var fmpFormat = document.getElementById('-format');    
     var listValue = myForm.myList.options[myForm.myList.selectedIndex].value;
     
     // Concatenate all the other search fields that allow input
     var otherValues = myForm.secondField.value + myForm.thirdField.value;

     if (listValue != '' && otherValues == ''){
          // A list item was selected (and data was not entered into any other fields)
          fmpFormat.value = "show_field.cdml";
     } else {
          // Either a list item was not selected, or data was entered into other fields
          fmpFormat.value = "hide_field.cdml";
     }    
     alert("-format=" + fmpFormat.value);
     return true;
}
</script>
</head>
<body>
<form name="form" action="FMPro" method="get" onsubmit="return dynamicSubmit(this);">
<input type="hidden" name="-db" value="test.fp5">
<input type="hidden" name="-lay" value="web">
<input type="hidden" name="-format" value="">
<input type="hidden" name="-find" value="">
<table>
<tr>
     <td>Scrolling List:</td>
     <td><select name="myList" style="width: 150px;">
               <option value="">Select one...</option>
               <option value="Apple">Apple</option>
               <option value="Dell">Dell</option>
               <option value="HP">HP</option>
               <option value="IBM">IBM</option>
               <option value="Sun">Sun</option>              
          </select></td>
</tr>
<tr>
     <td>Second field:</td>
     <td><input type="text" name="secondField" value=""></td>
</tr>
<tr>
     <td>Third field:</td>
     <td><input type="text" name="thirdField" value=""></td>
</tr>
<tr>
     <td><input type="submit"></td>
</tr>
</form>
</body>
</html>
______________________________________________________________
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Filemaker Grouping Fields and Button 1 470
Filemaker record reorder popup 2 390
Filtering portal results 3 68
Filemaker using sql database 5 51
Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now