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
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 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>
0
benjiartAuthor Commented:
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>
0
Mariano_PetersonCommented:
I think your CDML is wrong - it should instead read:
__________________________________________________
              <SELECT NAME='categorie' SIZE=1 >
                 [FMP-option: <field>, list=<value list>]
              </SELECT>

* <value list> specifies the VL to use
* <field> specifies the field whose value will be used to determine which option is selected.
__________________________________________________

The javascript will only work if you create two result files: "results_hide_field.html" and "results_show_field.html".
All that the javascript does is tell the form which page to use for the result.  Without the javasript, the form always asks for the same result page:
<input type="hidden" name="-format" value="results.html">

Note that in my example, the form does not specify a results page:
<input type="hidden" name="-format" value="">

In my earlier example, the "-format" value is specified dynamically (on the fly) when the user submits the form.  This is handled in the javascript code.  The js checks to see which input fields the user put a value into.  The js then sets the value for the "-format" parameter based on which <input> fields contain data.  At this point, the js can either set the "-format" parameter to "results_hide_field.html" or "results_show_field.html".  So - the input that the FileMaker CGI (web companion) receives will be the equivalent of:

<input type="hidden" name="-format" value="results_show_field.html">
   -or-
<input type="hidden" name="-format" value="results_hide_field.html">


By the way - since you're not using the value in <OPTION VALUE="">...text...</OPTION>, you'll have to change the following line in the JavaScript example
from:
     var listValue = myForm.myList.options[myForm.myList.selectedIndex].value;
to:
     var listValue = myForm.myList.options[myForm.myList.selectedIndex].text;


You'll also have to customize the js function for the specifics of your html page.  Make sure you change the following line to include all the other fields that should NOT contain search criteria if the intro field is to be displayed
from:
     var otherValues = myForm.secondField.value + myForm.thirdField.value;
to:
     var otherValues = myForm.--put input tag "NAME" here--.value +
                                myForm.--put input tag "NAME" here--.value +
                                myForm.--put input tag "NAME" here--.value +
                                ....continue for all your user-enterable input tags,
                                ....and end with ";"

__________________________________________________

If you've ever taken any introductory programming class or are willing to learn a tiny bit about regular programming, I very highly recommend that you ditch all efforts to learn CDML and move immediately to PHP.  Don't worry, you can still use FileMaker as your database.  PHP is a regular web programming language and is *_FAR_* more powerful and secure than CDML.  CDML is extremely limiting, and you constantly have to find/create elaborate work arounds for simple every day problems.  These simple problems (like the kind you're inquiring about) can be solved extremely easily with a regular web programming language.  PHP is an entirely different paradigm that really gives the programmer a lot of power.  I know this seems ridiculous, but CDML doesn't provide any means for doing math.  Nor does CDML allow you to see what data was sent from the web form before it is submitted to the database.  This is both dangerous and outragously limiting.  Almost all dynamic functionality in CDML must be performed using client side scripting (javascript), but client side scripting is very fragile and tedious to write since you don't know what type of browser your users will have - and nearly all browsers use slightly different versions of javascript.

I suggest learning PHP because the syntax is very similar to JavaScript, so you can hit two birds with one stone, so to speak.  Also, PHP is free (you'll need a web server, but don't worry; you can use Apache which is also free, and a first-class web server).  So financially the software won't set you back (but buying books to learn from will).  Also, PHP has many books written about it, and has an extensive world-wide install-base which means you can easily find help online for you problems.

If you go the PHP way, you don't need to know a single thing about CDML.  So I believe that learning CDML is just a waste of time.  Just my honest opinion.  IF you want to learn PHP just write back and I can recommend some resources.

-Mariano
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
benjiartAuthor Commented:
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
0
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.