Posted by Garry Jones on 10/11/06 07:43
I need to define an option value as selected. If the user was only going to
open this form and send it in I could just write "selected" next to the
value I want as default.
However, the user can subsequently open this form for editing. I then want
the option the user initially chose as being "selected" to remind the user
what he/she chose and give him/her a chance to change it.
The following code is the start of a the only way I know to do this. There
must be an easier way as there can not be a need for 3600 variables for one
funtion?
<option value="0" <?= $slt_tid0 ?> >00.00</option>
<option value="1" <?= $slt_tid1 ?> >00.01</option>
<option value="2" <?= $slt_tid2 ?> >00.02</option>
<option value="3" <?= $slt_tid3 ?> >00.03</option>
<option value="4" <?= $slt_tid4 ?> >00.04</option>
if i was to continue I would end with
<option value="3599" <?= $slt_tid3599 ?> >23.59</option>
because the values represent the minutes of the days in a timetable. Then I
would test each variable against the output queried from MySQl with this
if ($slt_tid0 == $sltres){
$slt_tid0 = "selected";
}elseif($slt_tid1 == $sltres){
$slt_tid1 = "selected";
}elseif($slt_tid2 == $sltres){
$slt_tid2 = "selected";
}elseif($slt_tid3 == $sltres){
$slt_tid3 = "selected";
}elseif($slt_tid4 == $sltres){
$slt_tid4 = "selected";
}
etc
The necessary variable is set to "selected" with this code, but again its
3600 values.
So I would like to know how this is "supposed" to be done before I write my
10 800 lines of code.
Thanks for any help in this matter.
Garry Jones
Sweden
Navigation:
[Reply to this message]
|