简体   繁体   中英

Checkbox does not hold checked status after disabling the checkbox

I have form with checkbox used in both add/edit mode but have scenario when in edit mode disable the checkbox with its value like checked or unchecked.

I have tried as below but not succeeded,

<input type="checkbox" disabled="disabled" checked="checked">

If an element is disabled, it's value is not posted along with the form, so while the checkbox appears checked, that information is not in the form data.

You may want to store the value in a hidden element, or (better, I think), let the server side script determine the proper default value if it is omitted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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