Help - Search - Members - Calendar
Full Version: How do you make Checkboxes and Radio Buttons READONLY?
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
Ann-Marie Foster
After competing the transaction I display and reconstruct a web page for viewing and printing. Checkboxes and Radio Buttons are restored to the saved check state but although set as READONLY they can be altered by the customer. How do I lock their setting?
pandy
According to the spec, I think it should be possible with the bolean readonly attribute. Only it doesn't work with radio and checkboxes for some obscure reason.

Is it possible for you to programmatically give all inputs but the checked ones the disabled attribute? That would prevent any changes. The downside is that the disabled values won't be sent when the form is submitted, but if this is only for display that shouldn't matter.

CODE
<input type="radio" name="fruit" disabled>Apple
<input type="radio" name="fruit" disabled>Pear
<input type="radio" name="fruit" checked>Banana
<input type="radio" name="fruit" disabled>Cherry


You could make all inputs disabled, but then the checked one will be grayed out, if that matters to you. It doesn't seem possible to change the color with CSS. It is for for example disabled text inputs, but it doesn't seem to work with radio buttons and checkboxes.
Ann-Marie Foster
Well I solved the problem with brute force, I put an "OnClick" on each button that calls the program that displayed them in the first place so any alteration attempts are immediately overwritten.
Christian J
QUOTE(Ann-Marie Foster @ Mar 20 2019, 06:17 AM) *

After competing the transaction I display and reconstruct a web page for viewing and printing. Checkboxes and Radio Buttons are restored to the saved check state but although set as READONLY they can be altered by the customer. How do I lock their setting?

Another idea might be to remove all form elements from the printable page and use images instead of real checkboxes.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.