Skip 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.

FX and value lists

Featured Replies

Hey,

I want a web page where users can edit existing records. I want some fields to have a drop-down list using values from a FileMaker value list as the options. I've got this much working fine. Also, if the record to be edited has a value for a particular field, I can get the option list to default to that value. For example:

echo "<select name='userTitle'>";

foreach ($userInfoValueList['valueLists']['Titles'] as $key=> $titleValue){

if ($titleValue == $userTitle){

echo "<option selected value='";

}else{

echo "<option value='";

}

echo $titleValue;

echo "'>";

echo $titleValue;

echo "</option>";

}

So if I have a record for Mr. John Doe, userTitle defaults to 'Mr.' If I have a record for Ms. Jane Doe, userTitle defaults to 'Ms.'

The problem is that if I have a record for Jane Doe (without a title specified), then on the web page it defaults to the first option in the list, resulting in Mr. Jane Doe, clearly wrong.

The only way I've been able to prevent this is to make a blank first entry in the value list so that it defaults to "". This works OK for static value lists like this. But this won't work for dynamic value lists.

So how do I get a value in a select list not to take the first option as the default when the record contains no data in FileMaker. How would I get Jane Doe to appear as Jane Doe, not Mr. Jane Doe.

I hope I haven't made this more complicated than it needs to be.

Thanks,

Dan

Try this:

echo "<select name='userTitle'>";

echo "<option value=''></option>";

foreach ($userInfoValueList['valueLists']['Titles'] as $key=> $titleValue){

if ($titleValue == $userTitle){

echo "<option selected value='";

}else{

echo "<option value='";

}

echo $titleValue;

echo "'>";

echo $titleValue;

echo "</option>";

}

All the best.

Garry

  • Author

Ugh! How could I have missed the obvious so easily?!

Thanks, Garry!

Dan

Obvious? Ha! It's obvious now that Garry's given the answer but I have to admit skipping the post because it did not occur to me, either. I was trying to wrap my noodle around the PHP part that I missed the simple hard code answer he enlightened us with...

echo "<option value=''></option>";

Doh! Yeah, obvious now.

--ST

Programming is like that!

It is always handy to have someone else to check your code. So many times I have had variable names wrong, something missing, simple procedures turn messy, and it has taken me ages to find it, whereas someone else can look at it and see it straight-away ???

All the best.

Garry

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.