PHP: Possible to automatically get all POSTed data And Multiple checkbox unchecked?

后端 未结 1 1571
傲寒
傲寒 2020-12-04 03:19

Hello friends i have a trouble.

I\'m trying to use this code to get dynamically, variables and values of a form, but there is a countless number checkbox, which may

相关标签:
1条回答
  • 2020-12-04 03:57

    Only "successful" controls are submitted. An unchecked checkbox or radio button is not "successful".

    You need to declare a default value with a hidden input. Make sure the hidden input comes before the checkbox so if the checkbox is checked it will override the default hidden input since the names are the same:

    <input name="p-sis-0110-1" type="hidden" value="0">
    <input name="p-sis-0110-1" type="checkbox" value="1">
    

    To use an array you need to explicitly define the indexes so they are the same:

    <input name="input[0]" type="hidden" value="0">
    <input name="input[0]" type="checkbox" value="1">
    
    0 讨论(0)
提交回复
热议问题