Click to See Complete Forum and Search --> : how to set the value to <select> dynamically


msg2ajay
08-17-2007, 02:58 AM
hi all,
I have a problem with <html:select> i am getting a value from the database
but it is not setting to my <select value>. Can any bady tellme what is the problem. My come is given below..



Code: ( text )
<html:select property="conttitle" styleClass="dropdown" value="${conttitle}">
<html:option value="1">1 - Mr</html:option>
<html:option value="2">2 - Ms</html:option>
</html:select>


thx in Adv,
HAN.

Yelgnidroc
08-17-2007, 04:44 AM
I assume you're using php & MySQL

<option value = '2' SELECTED>Ms</option>

ray326
08-17-2007, 09:42 AM
That would probably be a bad assumption since those look like Struts tags. ;)

You have to compare the value of each option to the value from the database and add the selected or selected="selected" attribute to the matching tag. It's something that is easier for me to do with scriptlets than with custom tags.