Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  170] [ 5]  / answers: 1 / hits: 18839  / 14 Years ago, thu, february 10, 2011, 12:00:00

After refresh the page, the user selected radio button is missing.
How can I always display the user's "selected radio button" even I had refresh the page?


<input name="radiobutton" type="radio" value="" id="all" checked />

radio with checked is not suitable, because it will always display the default radio button.


Below is my code:-


<form name="myfrm" id="myfrm" action="" method="post">
<input name="radiobutton" type="radio" value="" id="all" />
<label>All Languages</label>
<input name="radiobutton" type="radio" value="" id="english" />
<label>English</label>
</form>

More From » jquery

 Answers
10

You should conform to standards and give a value to every attribute. That means you need checked=checked



<input name=radiobutton type=radio value= id=all checked=checked />


And in case you were asking how to stick to what was selected previously: AFAIK, it is not possible with plain HTML. You need to bind a Javascript event that submits the selected radio button to your server and a dynamically generated page (by PHP, Python, whatever) that puts the 'checked=checked to the radio button that was submitted as checked.



EDIT:



As I see it, submitting the currently selected radio button to the server and generating your page dynamically might be overkill.


[#93802] Tuesday, February 8, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;