Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

using dependent dropdown list

Featured Replies

  • Newbies

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

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.

  • Author
  • Newbies

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!

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.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.