Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep radio buttons checked

Status
Not open for further replies.

joyceda59

Technical User
Apr 3, 2007
29
CA
Hi

I hav created a form that users can fill and submit. Some of the fields in the form hav radio buttons and checkboxes that users can select. Now, if a user makes some mistake filling the form, i want to form to tell the user he/she has made a mistake and i want the radio buttons to be checked to the value the had been inserted by the user before. I also want the values of the checkbox fields to be retained. Im not too good with this stuff. Plase help! Thx
 
This you will not be able to do via HTML/CSS only. You will need some kind of scripting language, either client side (like javascript or vbscript), which will do it before the refresh but is not very reliable (because it can be turned off) or server-side (like asp, php, perl, coldfusion, jsp, asp.net), which will reload the page but is more reliable.
 
Hi

Just make them [tt]disabled[/tt]. Note that this way those [tt]input[/tt]s will not be included in the sent [tt]form[/tt] data. Also note that there is no bulletproof solution for this, so if you want to be sure the second user will not change them, then do not process them at all and always keep their state set by the first user.
Code:
<input type="radio" name="one" checked="checked" disabled="disabled">
<input type="checkbox" name="two" checked="checked" disabled="disabled">

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top