?
Solved

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

Posted on 2003-11-17
6
Medium Priority
?
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

764 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