View Full Version : Radio Button: pre-selected?
03-04-2003, 04:02 PM
I have a form on my site that uses radio buttons, but I want the user to be able to return to the form to edit it. How do you make the radio button appear selected already. i.e. I am assuming it is something along the lines of the code below, but I can't get it to work.
<input type="radio" name="but1" value="1" select>
<input type="radio" name="but1" value="2">
03-04-2003, 04:08 PM
you got the right idea about using the "select", although, it should be "selected".....
are you adding these details to a database? ie: how is the user going to be editing the details when they go back to the page?
ps... you are from Loughborough... u play sports by any chance?! my bro's ex g'friend is from mount carmel (i think thats how u spell it!!) ......
03-04-2003, 04:22 PM
Thanks HomerUK, I'll give it a go. The data is held in a database, I'm using ASP.
Yeah, I live in Loughborough, although don't play much sport. It's famous for it's sports University so everbody assumes that everyone living there is a athlete... not me! Judging by some of the hefty women in the students union, I don't think many of the students do much sport either!!!
03-04-2003, 04:25 PM
OK, tried what you said, but it still doesn't work. Any ideas?
<input type="radio" name="sec1_1" value="1" "selected">
<input type="radio" name="sec1_1" value="2">
03-04-2003, 04:40 PM
if you're using asp, you will need to get the details from the database and write the radio button out using the ASP..... I'm not great with ASP... but something like:
if rs("option1") == "on" then
'draw the radio button selected
response.write "<input type=""radio"" name=""x"" selected>"
'draw the radio button no selected
response.write "<input type=""radio"" name=""x"">"
so basically you need to get the field in the DB where the value of the radio buttons is being stored and if they should be "selected" then draw them out as "selected"... if not, then dont!
Hope that helps a wee bit?!
03-04-2003, 06:11 PM
It is "checked" rather than "selected".
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.