Solved

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

Posted on 2003-11-17
6
339 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
ID: 9766201
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
ID: 9766226
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
ID: 9768464
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
ID: 9773025
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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