Minhaj Ahmed
Minhaj Ahmed

Reputation: 17

I want to set radio button's value dynamically through database in jsp but unable

I want to set radio button's value dynamically through database in jsp but its only set the string upto space rest are ignored ex:

<input type="radio" name="ansrd" value=<%=request.getAttribute("optD")%>>   

ex: request.getAttribute("optD") returns a string James watt but only "James" stored in value.

Upvotes: 1

Views: 871

Answers (1)

Ramanlfc
Ramanlfc

Reputation: 8354

put "" for value attribute, like this

<input type="radio" name="ansrd" value="<%=request.getAttribute("optD")%>" > 

otherwise your <input> in generated html will end up like

<input type="radio" name="ansrd" value=james watt>  

where the brower will interpret watt as a custom attribute

Upvotes: 2

Related Questions