Skip to content Skip to sidebar Skip to footer

Maintain The State Of A Radio-toggled Div After Page Reload

In my form there are some radio buttons - when the radio is selected - the div appears, when another one is selected - the div hides. After submitting a form if there are some erro

Solution 1:

Why don't you use ajax to submit the form? You will not face these kind of issues. Well to answer your question you can try this.

//I don't know how many radio buttons are there on the page and what there names are
//you can accordingly change the radio button selector to check if it is checked or not

$(document).ready(function() {
     if($("input:radio:first").is(":checked"))
         $('divToShowHide').show()
     else
         $('divToShowHide').hide()
});

Post a Comment for "Maintain The State Of A Radio-toggled Div After Page Reload"