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.

Drop down lists won't retain previous data

Featured Replies

I have a survey page that uses FMFind to find an existing record which is then updated by new survey data for comparison.

http://www.acwa.asn.au/Pages/djppostcourseevaluation.php?recid=20989

The drop-down lists don't display previous data.

For example:

// variables extracted from database by FMFind
$djpenjoy =   $findnewevaluationData['djpenjoy'][0];

//isset code
if (isset($_REQUEST['djpenjoy'])) $djpenjoy = $_REQUEST['djpenjoy'];

 

//select code<select name="djpenjoy" size="1">
<?php
$enjoyoptions = array('' => '', 'Not at all' => 'Not at all', 'Somewhat' => 'Somewhat', 'Almost all' => 'Almost all', 'Very much' => 'Very much');
$selected = '';
if (isset($_REQUEST['djpenjoy']) && in_array($_REQUEST['djpenjoy'], $enjoyoptions)) {
// If someone has selected an option (i.e. previously submitted the form) then change the default value
$selected = $_REQUEST['djpenjoy']; 
}
// Loop through each option in $opts adding it as an option to the select. If the key from the array matches the selected (default) value then mark the item as selected
foreach ($enjoyoptions as $k => $v) { 
echo '<option value="' . htmlentities($k, ENT_QUOTES) . '"';
if ($k == $selected) {
echo ' selected="selected"';
}
echo '>' . htmlentities($v, ENT_QUOTES) . '</option>'; 
}
?>
 </select>

What am I missing?

This will work if there is a Request for djpenjoy set in the loading URL. But if $djpenjoy is set, then it won't, as the array check to $enjoyoptions requires a Request...

Try changing this line to:

if (isset($djpenjoy) && in_array($djpenjoy, $enjoyoptions)) {

 

  • Author

It's now showing selected data when the page is returned to during a submission process but it doesn't display existing data from the database from a previous submission. 

Assuming the $findnewevaluationData['djpenjoy'][0]; returns a value, then there needs to a test around whether $dpenjoy has already been set... Try:


// variables extracted from database by FMFind
$djpenjoy = $findnewevaluationData['djpenjoy'][0];

//isset code
if ( $dpenjoy == "") {
	if (isset($_REQUEST['djpenjoy'])) $djpenjoy = $_REQUEST['djpenjoy'];
}

 

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.