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

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
benjiartAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mariano_PetersonCommented:
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
lesouefCommented:
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
benjiartAuthor Commented:
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
Mariano_PetersonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.