search

Home  >  Q&A  >  body text

php - js gets form id value


As shown in the picture, when I click to open in batches, how can I use js code to get the id value in the box?
This form is read from the database The data is looped out,
<td class="center"><input class="aids" type="checkbox" name="ids[]"

                                                       value="{$val['id']}"></td>

This is the box code

扔个三星炸死你扔个三星炸死你2760 days ago744

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-10 09:49:38

    var id_list = [];
    $(".btn").click(function(){
        $(".aids").each(function(){
            if($(this).is(":checked") == true) {
                id_list.push($(this).val())
            }
        });
        alert(id_list)
    });

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-10 09:49:38

    Brother, I see you again, Smile manually.jpg

    <script>
        $(document).ready(function() {
            $("#click").click(function() {
                var ids=[];
                $("input[name=ids[]]:checked").each(function() {
                    ids.push($(this).val()); //push添加元素到数组末尾
                });
                alert(ids); //alert打印数组
            });
        });
        
    </script>

    reply
    0
  • Cancelreply