简体   繁体   English

如何提交复选框值,即使其禁用

[英]how to submit checkbox value even its disabled

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 我已经禁用了该复选框并显示为已禁用,但未提交php操作文件的值

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 />

In short, PHP will not send "disabled" form elements between pages. 简而言之,PHP将不会在页面之间发送“已禁用”的表单元素。

However, readonly="readonly" should work instead of disabled="disabled" . 但是,应该使用readonly="readonly"而不是disabled="disabled" The major difference visually is that the form element wont be greyed out, you'd have to handle that yourself. 视觉上的主要区别是form元素不会显示为灰色,您必须自己处理。

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 一种不同的解决方案是使用Javascript读取表单元素,而不考虑其禁用状态,将其与其余表单字段一起序列化,然后以这种方式提交有效负载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM