How to POST or submit an input checkbox that is disabled with HTML?

Spread the love

Sometimes, we want to POST or submit an input checkbox that is disabled with HTML.

In this article, we’ll look at how to POST or submit an input checkbox that is disabled with HTML.

How to POST or submit an input checkbox that is disabled with HTML?

To POST or submit an input checkbox that is disabled with HTML, we add a hidden input with the same name and value of the disabled checkbox.

For instance, we write

<input
  type="checkbox"
  checked="checked"
  disabled="disabled"
  name="Tests"
  value="4"
/>SOME TEXT

<input type="hidden" id="Tests" name="Tests" value="4" />

to add a disabled checkbox with the value attribute set toi 4.

And we add a hidden input with the same name and value attribute values as the checkbox.

Then the hidden input’s value will be submitted with the same name and value as the checkbox.

Conclusion

To POST or submit an input checkbox that is disabled with HTML, we add a hidden input with the same name and value of the disabled checkbox.

Leave a Reply

Your email address will not be published. Required fields are marked *