Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Radio Button: pre-selected?

    Hi people.

    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">

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    hey,

    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!!) ......

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Loughborough

    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!!!

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Still doesn't work!

    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">

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    hey,

    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:

    Code:
    <%
    
    if rs("option1") == "on"  then
    
     'draw the radio button selected
     response.write "<input type=""radio"" name=""x"" selected>"
    
    else
    
     'draw the radio button no selected
     response.write "<input type=""radio"" name=""x"">"
    
    end if
    %>
    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?!

  • #6
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    It is "checked" rather than "selected".
    Last edited by arnyinc; 03-04-2003 at 05:22 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •