Link to home
Start Free TrialLog in
Avatar of benjiart
benjiart

asked on

using fmp-if with an option value scrolling list?????

hello i have a cdml search page with different categories which is connected to a filemaker database the challenge is ;  when a user uses the search option category (which is a scrolling list)  a field will be visible  in the search results  else any other search method this field must not be not visible.  is this possible???  help would be greatly apreciated
thank you in advance

benjamin martin
Avatar of Mariano_Peterson
Mariano_Peterson

I thought about this some more and think I found a way to make this work using JavaScript.  You'd have to configure two CDML pages, one that shows the field (show_field.cdml) and the other that doesn't (hide_field.cdml).  The JavaScript code would adjust the form to use the appropriate format file depending upon the selections made in the form.

Here is an example that uses a message box to show you what the "-format" input tag has been set to.  Please note that if you MUST hide the other field, this is not a secure method as the user could simply read the source code to learn what URLs you're using, and then type one into a browser address bar.

<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>
Avatar of benjiart

ASKER

thanks for the javascript method,  im not sure i understand this exactly in this case figure. but i think i didnt explain the situation very well, im really new to filemaker and cdml ive been copying and pasting from the cdml toolbox ;-))  
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 will appear , if he enters a date or record number the text field should not load.  ive pasted the code found on the scroll down menu below
the line.
is this possible to use inside of the java script code??  
thanks again for all the help,

_________________________________________________________
<INPUT TYPE=hidden NAME="-op2" VALUE=eq>
              <SELECT NAME='categorie' SIZE=1 >
                <OPTION VALUE="">- no selection -
                <OPTION selected [FMP-ValueListItem]> [FMP-VALUELISTITEM] [/FMP-VALUELIST]
              </SELECT> </td>
          </tr>
ASKER CERTIFIED SOLUTION
Avatar of Mariano_Peterson
Mariano_Peterson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hello thanks for all the help we are testing your javascript method but cant sweem to get it to work completely  the code you sent us is
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="">

what we dont understand is how the hide_field.cdml works dynamically and how it relates to the creation of results_hide_field.html which you told us to create in your follow up answer  are these 2 different methods??  when we are able to get a results page it is always the same otherwise we get a message that no format file has been specified ????
if you can help us that would be great
thanks alot
benjamin