久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用jQuery獲取所有選中復(fù)選框的值

How to get the values of all checked checkboxes using jQuery(如何使用jQuery獲取所有選中復(fù)選框的值)
本文介紹了如何使用jQuery獲取所有選中復(fù)選框的值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我不知道如何傳遞復(fù)選框的選定值.任何幫助或建議都會對我有很大幫助.

I don't know how to pass the selected values of the checkboxes. Any help or suggestions will be a big help for me.

到目前為止,這是我的代碼,我一直在傳遞復(fù)選框的值

As of now here is my code I am stuck in passing the values of the checkboxes

<table>
<?php
foreach($response as $item){
    echo '<tr><td><input type="checkbox" value="' .$item['id']. '"></td><td>' . $item['name'] . '</td></tr>';
}
?>
</table>
<button type="button" class="btnadd">AddSelected</button>
<script type="text/javascript">
    $(function() {
        $('.btnadd').click(function() {
            $.ajax({
                url: 'process.php',
                type: 'post',
                data: {  }, // what should I put here to pass the value of checked checkboxes
                success: function(data) {}
            });
        });
    });
</script>

process.php

<?php
$array_ids = $_POST['ids']; // this will retrieve the id's
?>

推薦答案

試試這個.

HTML 代碼

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">

    $(document).ready(function(){
        $('.btnadd').click(function(){
            var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();

            $.ajax({
                url: 'loadmore.php',
                type: 'post',
                data: { ids: checkValues },
                success:function(data){

                }
            });
        });
    });

</script>

<input type="checkbox" name="checkboxlist" value="1" checked="checked" />
<input type="checkbox" name="checkboxlist" value="2" checked="checked" />
<input type="checkbox" name="checkboxlist" value="4" />
<input type="checkbox" name="checkboxlist" value="5" checked="checked" />
<input type="checkbox" name="checkboxlist" value="6" />?

loadmore.php 代碼

<?php

    print_r($_POST['ids']);

?>

在 loadmore.php 中輸出

Array
(
    [0] => 1
    [1] => 2
    [2] => 5
)

就是這樣.

干杯.

這篇關(guān)于如何使用jQuery獲取所有選中復(fù)選框的值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 国产精品九九九 | 中文字幕成人 | 亚洲精品www久久久久久广东 | 精品国产1区2区3区 一区二区手机在线 | 91福利网址| 99re在线视频 | 午夜激情小视频 | 国产日韩视频 | 一级免费在线视频 | 久草在线免费资源 | 成人av播放 | 中文字幕在线观看一区 | 日本成年免费网站 | 精品美女久久久 | 色综合久久久 | 91久久久久久| 中文字幕日韩一区 | 综合第一页| 99热精品在线观看 | 中文字幕日韩一区二区 | 日韩中文一区 | 久久精品亚洲精品国产欧美 | 欧美一区二区在线 | 久草网站 | 日韩在线一区二区三区 | 亚洲国产一区二区三区 | 色秀网站 | 欧美日韩综合一区 | 午夜欧美一区二区三区在线播放 | 国产精品久久亚洲7777 | 久久精品国产免费 | 久久久久国产一区二区三区不卡 | 一区二区在线免费观看视频 | 国产精品视频网 | 精产国产伦理一二三区 | 91在线资源 | 99re6在线视频 | 看片一区 | 欧美精品片 | 污污的网站在线观看 | 国产精品一区二区不卡 |