0

i have a web page which show orders invoices with price and when user select the items checkbox and click submit its works. i want user dont have permission uncheck and form must work with any single item is checked. i have already disabled the checkbox and show disabled but value is not submitting for php action file

The Code is below:

<input name="orderNo[]" <?php  if ($SQLRow["priceStatus"]=="Received") { ?> disabled="disabled"<?php } ?> type="checkbox" id="orderNo[]" value="<?php echo $SQLRow["orderNo"];?>" class="chk1"  disabled checked />
Aayaan
  • 31
  • 5
  • Sorry I was wrong with my answer, see this question for suggestions: https://stackoverflow.com/questions/155291/can-html-checkboxes-be-set-to-readonly – chrki Jun 30 '17 at 23:01
  • i have already checked this link discussion i could not solve and dont understand i have only this code and i cant with working i dont know why – Aayaan Jun 30 '17 at 23:04
  • You shouldn't rely on that checkbox no matter what. It's client side code. A visitor can easily remove the disabled attribute and uncheck it anyway. Or simply modify the REQUEST headers. The checkbox should be there as a form of information to your visitor. Nothing more. – icecub Jun 30 '17 at 23:13

1 Answers1

0

In short, PHP will not send "disabled" form elements between pages.

However, readonly="readonly" should work instead of disabled="disabled". The major difference visually is that the form element wont be greyed out, you'd have to handle that yourself.

A way different solution could be to use Javascript to read the form element regardless of disabled status, serialize it alongside the rest of the form fields, and submit the payload that way

RedactedProfile
  • 2,748
  • 6
  • 32
  • 51