Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visually disable a checkbox but allow it to still submit its value

I have a checkbox which is updated from other selections but it is important to show the checked status to the user. However I also want it to be read only in functionality and represented as such in the display.

  • It works fine by disabling the checkbox (gives the greyed out box to assist the user visually) however this means upon submitting the value is not saved.

  • Conversely, if I set the checkbox to read-only it disables the checkbox but still appears like a normal checkbox.

I kinda want a bit from each, a checkbox that submits it's value but looks like a disabled checkbox and still displays its check status... does anyone have any ideas?

like image 497
WestieUK Avatar asked Feb 09 '11 16:02

WestieUK


People also ask

How do you disable submit button until checkbox is checked?

checked) { // Disable button when checkbox is selected submitButton. disabled = true; } else { // Enable button when checkbox is deselected submitButton. disabled = false; } }); Below, you'll find some examples of different ways to solve the Disable Submit Button Until Checkbox Is Checked Javascript problem.


1 Answers

Use a hidden field <input type="hidden" />. Populate the hidden with the same values you would expect from the checkbox. This way the visual element is separate from the data element and you will not have these concerns.

like image 185
Josiah Ruddell Avatar answered Nov 15 '22 19:11

Josiah Ruddell