Newbies A-Solutions Posted March 23, 2011 Newbies Posted March 23, 2011 Hi, i generated a file, using php site assist, to add a record to my fm database. The problem I have is that one dropdown content is dependent on another dropdown list. for example I have a dropdown list of different sports (basketball, soccer, tennis) and then once that is chosen, in the second dropdown list contains the different teams of that particular sport. In fm itself and with IWP it works like a charm, my relations are all correct and working. Now the questions is, how do I do that with php? that's the code site assist generated for the dropdowns: <td class="field_data"> <?php $fieldName = '_k2_wedstrijdID';?><?php $fieldValue = $record->getField('_k2_wedstrijdID', 0) ; ?><select class="fieldinput" name="<?php echo getFieldFormName($fieldName, 0, $record, true, 'POPUPMENU', 'number');?>"> <?php $menuOptions = getMenu($layout->getValueListTwoFields('wedstrijdnamen', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), $fieldValue, $fieldName, 'number', $submitDateOrder); if ($fieldValue == "") { $selected = "selected"; } else { $selected = ""; } $selected = "selected"; $menuOptions .= "<option value='' $selected></option>"; echo $menuOptions;?> </select> </td> for the second dropdown its allmost the same: <td class="field_data"> <?php $fieldName = '_k2_ploegid';?><?php $fieldValue = $record->getField('_k2_ploegid', 0) ; ?><select class= "fieldinput" name="<?php echo getFieldFormName($fieldName, 0, $record, true, 'POPUPMENU', 'number');?>"> <?php $menuOptions = getMenu($layout->getValueListTwoFields('ploegen', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), $fieldValue, $fieldName, 'number', $submitDateOrder); if ($fieldValue == "") { $selected = "selected"; } else { $selected = ""; } $selected = "selected"; $menuOptions .= "<option value='' $selected></option>"; echo $menuOptions;?> </select> </td> Thank you all for your help! greetings
dansmith65 Posted March 23, 2011 Posted March 23, 2011 The only way I could think of doing this is to use ajax http://api.jquery.com/jQuery.get/ You would have to create a script that you can pass the value of the first drop-down list to; that script would have to perform a search of some sort to get the related values. Then you call that script via javascript when the first drop-down input is changed, and use the script return result to change the available options for the 2nd dropdown. I'm curious to see if anyone has any other ideas of how to do this.
Newbies A-Solutions Posted March 29, 2011 Author Newbies Posted March 29, 2011 Thx for you reply Dansmith65, I'm also thinking this is the only way to do it.... Do you have any idea where i could some example scripts of this or maybe a tutorial :s ? or do you think it will be possible by using fm scripts? thx & grtz!
dansmith65 Posted March 29, 2011 Posted March 29, 2011 Since the web page content needs to change after the page has loaded, I don't think you can do it with FileMaker scripts. (at least, not ONLY with FileMaker scripts) I don't know of a tutorial; you may be able to find something if you search for it. I recently used Ajax for the first time, and utilized the jQuery documentation I already gave you a link to.
Recommended Posts
This topic is 5244 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now