[英]How do i know what values have been changed in the table in jquery
I have a Html Table which consists of rows that were generated dynamically (from PHP) and each row conatins the select box and textbox with the values. 我有一个HTML表格,该表格由动态生成(从PHP)生成的行组成,每行都将选择框和文本框包含值。 Now how do i know which row has been changed (i mean Select box and textbox). 现在,我如何知道哪一行已更改(我的意思是选择框和文本框)。 Iam looking to have a list of (1,3,5,7) rows that have been changed so that i can pass them to the hidden and retrive in php 我正在寻找具有已更改的(1,3,5,7)行的列表,以便我可以将它们传递给隐藏的行并在php中检索
("#tb11").change(function(){
//Code
});
You can monitor object for changes. 您可以监视对象的更改。 Give the input's (I'm assuming they are inputs) a class of monitor
and run 给输入的(我假设它们是输入)一类monitor
并运行
$(".monitor").bind("keyup", function(event){ /* Code */ });
That will give you the index of the row, which has been changed 这将为您提供已更改的行的索引
(function() {
$("table").change(function(e) {
alert($(e.target).closest("tr").index());
});
})();
try this code: 试试这个代码:
$("#tb11 input").change(function(){
// Gets the parent row of the item that has been changed and adds a class of changed
$(this).parent().parent().addclass('changed');
});
You will need to give each row a unique id number, and use the following code to handle the submission: 您将需要为每行赋予唯一的ID号,并使用以下代码来处理提交:
function submitForm() {
$('.changed').each(function () {
// Will loop through each row that has been changed and post a value based on the id attribute
var rowId = $(this).attr('id');
// post the value of your row id to php
$.post('myurl.php?rowId='+rowId, function(data) {
//callback method for succesfull post
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.