...

View Full Version : select box default value



o0O0o.o0O0o
06-02-2009, 07:48 AM
is there any way to set the default value of select box
I HAVE




<SELECT NAME='bar_FOO' >


<OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION>

</SELECT>

I am not auto generating the options from database but i want to pre select the field if user want to edit their detail

abduraooft
06-02-2009, 09:38 AM
Add selected="selected" (http://htmldog.com/reference/htmltags/option/) to the required option

o0O0o.o0O0o
06-02-2009, 10:57 AM
BUt the problem is i have 20 predefined option tags hard coded in html
and in database i have only value

so i can't use selected

abduraooft
06-02-2009, 11:04 AM
have a look at http://www.codingforums.com/showthread.php?t=166026

o0O0o.o0O0o
06-02-2009, 11:21 AM
that can be the other way.
Can i do like this


<select>
<option value="<?php echo value ?>" selected="selected"><?php echo value ?> </option>
<OPTION VALUE="4" > </OPTION>
<OPTION VALUE="4" > </OPTION>
<OPTION VALUE="4" > </OPTION>
<OPTION VALUE="4" > </OPTION>

</select>

I mean one extra row for the item in database
Although there will be duplicate row but solves the purpose



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum