Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Radio Button Keeps Resetting on Submit

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27676
    realph
    Participant

    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?



    Buying


    Renting

    Thanks in advance!

    #78158
    Eclipse
    Member

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

    #78159
    Rob MacKay
    Participant

    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

    http://www.w3schools.com/tags/ref_eventattributes.asp

    #78140
    Eclipse
    Member

    Thanks Robskiwarrior

    #75783
    realph
    Participant

    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)
  • The forum ‘JavaScript’ is closed to new topics and replies.