I have Multiple radio button with same name in it of array and have same values as 1

后端 未结 1 1298
隐瞒了意图╮
隐瞒了意图╮ 2021-01-28 20:02

I have multiple radio button name in array with same values as 1 for all. I need want to get if uncheck means set as zero how can I do that. Below is my code

check image

相关标签:
1条回答
  • 2021-01-28 20:38

    use it like.

        <form method='post' id='userform' action='test2.php'> <tr>
            <td>Trouble Type</td>
            <td>
            <input type='checkbox' name='checkboxvar[]' class="check" value='1'>1<br>
            <input type='checkbox' name='checkboxvar[]' class="check"  value='1'>2<br>
            <input type='checkbox' name='checkboxvar[]'  class="check"  value='1'>3
            </td> </tr> </table> <input type='button' class='buttons'> </form>
    
    <script type="text/javascript">
            $(document).ready(function(){
                $('.buttons').click(function(){
                    var checkbox_arr = [];
                    $('.check').each(function(){
                        checkbox_arr.push(+$(this).is( ':checked' ));
                    });
                    console.log(checkbox_arr);
                });
            });
        </script>
    
    0 讨论(0)
提交回复
热议问题