Force a checkbox to always submit, even when unchecked

后端 未结 7 1357
粉色の甜心
粉色の甜心 2020-12-01 23:36

I have an html form and i would like ALWAYS to have checkboxes to submit a value. How can i do that? I have one idea but i havent tried it and i am unsure if its the best wa

7条回答
  •  长情又很酷
    2020-12-02 00:15

    Thanks to @Lazarus' idea, also mentioned by @BalusC, you can add an additional control to the form:

    
     My checkbox
    

    Checkbox and the hidden fields must have the same name. The hidden input is always submitted as a default value. If the checkbox is checked then also it's submitted. So you have a list of 2 values for parameter "checkbox1", that you have to treat at server side.

    ...maybe a

    提交评论

提交回复
热议问题