Hi MWNN,
I know how you feel. I asked the same question awhile ago, and I believe Leatherback gave me these function for dropdown menus and checkboxes.
makeDropList.php
function makeDropList($name,$list,$selected="")
{
// $name select name
// $list array of value, label pair
// $selected selected value
global $x;
global $label;
foreach($list as $value=>$label)
{
if(($_SESSION[$label] != '') || ($selected == $value)) // Are you sure you stored the label?
{
$options .= '<option selected value="'.$value.'">'.$label.'</option>';
}
else
{
$options .= '<option value="'.$value.'">'.$label.'</option>';
}
}
$dropList = '<select name="'.$name.'" tabindex="'.$x.'">'.$options.'</select>'."\n";
return $dropList;
}
makeCheckboxList.php
function makeCheckboxList($name,$list,$selected="") {
global $x;
while(list($value,$label) = each($list)) {
if($value['enabled']=='1') {
$options .= '<input name="'.$name.'" type="checkbox" value="'.$value.'" tabindex="'.$x.'" checked="checked"/> '.$label.'<br />';
} else {
$options .= '<input name="'.$name.'" type="checkbox" value="'.$value.'" tabindex="'.$x.'" /> '.$label.'<br />';
}
}
return $options;
}
Then in your form call them this way.
<form>
include('makeDropList.php');
$x='1'; //tabindex value
$choices = array( "" => "Choose one!", "1st choice" => "1st choice", "2nd choice" => "2nd choice"); // default for empty selected
$list = makeDropList('Choice',$choices,$choices);
echo $list;
echo '<br><br>';include('makeCheckboxList.php');
$x='2'; //tabindex value
$choices2 = array( "" => "Pick One!", "A" => "A", "B" => "B"); // default for empty selected
$list2 = makeCheckboxList('Choice2',$choices2,$choices2);
echo $list2;
</form>
These save me a ton of time.
Let me know if they are what you were envisioning.
Enjoy,
Don