Originally posted by TimNoob
Sorry but I am really a noob 🙂
Where is $myvalue declared?
How do i adapt this to work with the "<select multiple...." which i am using which is an array?
What is bla?
ok, i'm running. go back.
Let be $myvalue the value you have to display. It's submitted from your post to PHP_SELF. It's the name of listbox.
I think in your code there is some code like this:
while("there_is_any_option")
{
echo "<OPTION value='some_value' >my sel</OPTION>";
}
to make on the fly the "<select multiple ..."
or something like
<OPTION value='some_value1' >my sel 1</OPTION>
<OPTION value='some_value2' >my sel 2</OPTION>
<OPTION value='some_value3' >my sel 3</OPTION>
<OPTION value='some_value4' >my sel 4</OPTION>
<OPTION value='some_value5' >my sel 5</OPTION>
to make a static "<select multiple ..."
I'm rigth?
Well, before any close char (">") you have to check if the $myvalue is the same as current value. If is, echo SELECTED (or selected="selected" for some that work with XHTML).
example:
while("there_is_any_option")
{
echo "<OPTION value='some_value'";
if($myvalue="some_value") echo " SELECTED "; //<- look beginning/ending space...
echo ">my sel</OPTION>";
}
//or
<OPTION value='some_value1' <?if($myvalue="some_value1") echo " SELECTED ";?>>my sel 1</OPTION>
<OPTION value='some_value2' <?if($myvalue="some_value2") echo " SELECTED ";?>>my sel 2</OPTION>
<OPTION value='some_value3' ...
Ps:"bla" it's for any_to_do, anything... :p