Hi everyone,
I am using a function on my forms and it works great except when a user does not complete an item on my form. I know the browsers 'should' retain their choices, but some don't and a significant amount of them are complaining so I am attempting to resolve this issue.
Here is the function I use... (Note: I added the "if(($SESSION[$label]) !=''){" to try and retain their choices, but it doesn't work.)
function makeDropList($name,$list,$selected="") {
// $name select name
// $list array of value, label pair
// $selected selected value
global $x;
global $label;
while(list($value,$label) = each($list)) {
if(($_SESSION[$label]) !=''){
$options .= '<option value="'.$value.'">'.$_SESSION[$label].'</option>';
} else {
$options .= '<option value="'.$value.'">'.$label.'</option>';
}
}
$dropList = '<select name="'.$name.'" tabindex="'.$x.'">'.$options.'</select>'."\n";
$dropList = ereg_replace("value=\"$selected\"","value=\"$selected\" selected",$dropList);
return $dropList;
}
Then I include it and define the array...
$x='1'; //tabindex value
$languages = array("" => " ", "Sr." => "Sr.", "Prof." => "Prof.", "Dr." => "Dr.", "Miss" => "Miss", "Mr." => "Mr.", "Mrs." => "Mrs.", "Ms." => "Ms."); // default for empty selected
$list = makeDropList('Title',$languages,$language);
echo $list;
?>
I tried making it global in the function and that did not resolve it.
Any help would be appreciated.
Thanks,
Don