jquery从PHP中选定的行中获取内容 [英] jquery to fetch the contents from a selected row in php

查看:93
本文介绍了jquery从PHP中选定的行中获取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是源代码,当我检查checbox而不是获取选定的内容,而不是从表格中获取所有内容...任何人都可以发现我的代码中有什么错误...感谢你的时间



pre $ for(k = 0; k <= 9000; k ++){

//每次更改(j = 0; j <= numOflimit; j ++){
($#
$ b $(#status+ k).click
var product_name = encodeURIComponent($('#product_name'+ j).val());
alert(product_name);
var barcode = encodeURIComponent($('#barcode'+ j ).val());
var Quantity = encodeURIComponent($('#Quantity'+ j).val());
var cart = product_name + barcode + Quantity;
alert( cart);
$('#cart1')。val(cart);

}

});


});


解决方案

这里有两个循环。外部似乎将一个单击处理程序附加到所有行(或每个行的复选框)。但内在的一个没有意义。结果是,无论您点击哪个复选框,它都会迭代所有行并收集值。


Here is the source code , its not able to fetch the selected content when i check the checbox rather its taking all the contents from the table ... Can anyone spot what mistake is in my code... thanks for ur time

for(k=0;k<=9000;k++) {

    //each change

    $("#status"+k).click(function() {

        for(j=0;j<=numOflimit;j++) {

            var product_name = encodeURIComponent($('#product_name'+j).val());
            alert(product_name);
            var barcode = encodeURIComponent($('#barcode'+j).val());
            var Quantity = encodeURIComponent($('#Quantity'+j).val());
            var cart=product_name + barcode + Quantity;
            alert(cart);
            $('#cart1').val(cart);  

        }

    });


});

解决方案

You have two loops here. The outer one seems to attach a click handler to all rows (or to the checkboxes of each row). The inner one however makes no sense. It's result is that no matter what checkbox you click, it will iterate over all rows and collect the values.

这篇关于jquery从PHP中选定的行中获取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆