Treehouse: Grow your CSS skills. Land your dream job.

Radio Button Keeps Resetting on Submit

  • # November 2, 2010 at 9:55 am

    Hey there,

    I’ve got these two radio buttons, the problem is when you click on the ‘Renting’ radio button and submit the form the radio buttons reset back to the default ‘Buying’ button. Any idea how to stop the radio button resetting every time?



    Thanks in advance!

    # November 2, 2010 at 11:04 am

    You call for a javascript event without declaring the script inside your html, is that possible?

    # November 2, 2010 at 11:21 am

    Realph it goes back because by default checked=”checked” is on the Buying – so when the page loads (if it has to reload on submit) you will get that one.

    You could create a hidden field and use the input value to build the page next time round by putting in the checked by php “if else” statement… or something like that :)

    This is for you Eclipse :D

    # November 2, 2010 at 12:01 pm

    Thanks Robskiwarrior

    # November 15, 2010 at 1:32 pm

    Hey Robskiwarrior,

    Thanks for the help but could you possibly elaborate?

    I’ve taken the ‘checked=”checked”‘ off and it’s removed the checked Radio Button, what kind of workaround would I have to do if I wanted the button to stay checked on what was selected before the page reloaded?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.