Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ How do you make Checkboxes and Radio Buttons READONLY?

Posted by: Ann-Marie Foster Mar 20 2019, 12: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?

Posted by: pandy Mar 20 2019, 04:37 AM

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.

Posted by: Ann-Marie Foster Mar 20 2019, 10:00 AM

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.

Posted by: Christian J Mar 20 2019, 01:56 PM

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.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)