|
Posted by Shelly on 12/29/05 06:49
OK, I fixed it, but I know why it didn't work before.
The if test stuff was in an include file (that is bracketed by <?php ?>.
When I cut and pasted that code into inline code, it worked. The problem
was that the include file was at the beginning of the page, so the test was
before getting any values. Some times the stupid errors are the hardest to
find.
Shelly
"Shelly" <sheldonlg.news@asap-consult.com> wrote in message
news:e8CdnYQ_043p0S7eRVn-jw@comcast.com...
> Oops, here is the output:
>
> selHint_2=1 index=0 option value="0" selected Family member's name
> index=1 option value="1" Mothers maiden
>
>
>
> "Shelly" <sheldonlg.news@asap-consult.com> wrote in message
> news:Z5mdnTRRsdh81y7eRVn-oQ@comcast.com...
>> 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
>>
>>
>>
>>
>>
>
>
[Back to original message]
|