|
Posted by Shelly on 12/29/05 04:33
OK, I am at a toral loss after having programmed for forty years.
Here are my results:
selHint_2=1
It is clear that for the second time through the loop ($i=1) that
$index=1 and $selHint_2=1, while for the first pass through ($i=0) $index=0
and $selHint=1. Yet, the " selected " comes up for the first time and not
for the second. It should be the other way around. Any clues?
Shelly
Here is the code:
$numHint_2 = 2;
$hint_2_Lookup = array(0, 1);
$hint_2 = array();
$hint_2[] = " Family member's name";
$hint_2[] = " Mothers maiden name";
$foo = ""; // put in for debugging only
$tmpHint2 = array();
$tmpHint2[] = '<td class="stdBold"' . $readonly . '>';
$tmpHint2[] = '<select name="hint_1" value="" >';
for ($i=0; $i<$numHint_2; $i++) {
$index = $hint_2_Lookup[$i];
if ($index == $selHint_2) {
$sel = " selected ";
} else {
$sel = "";
}
$tmpHint2[] = '<option value="' . $index . '"' . $sel . '>' .
$hint_2[$i] . '</option>';
// next line put in for debugging only
$foo .= 'index=' . $index . ' option value="' . $index . '"' .
$sel . $hint_2[$i]. "<br>";
}
$tmpHint2[] = '</select></td>';
$selHint_2 = $_SESSION['vmHint_2']; // put in for
debugging only
echo "selHint_2=" . $selHint_2 . "<br>"; // put in for
debugging only
echo implode("\n",$tmpHint2)."\n";
echo $foo; // put in for debugging only
index=0 option value="0" selected Family member's name
index=1 option value="1" Mothers maiden
Navigation:
[Reply to this message]
|