Reputation: 2325
I am creating a dynamic table using java script and jquery, one of my project requirement is a select box in a row cell,
From the this SO link i am able to place a on click listener on a table row which gives me id of table row and cell(tr and td) but i am not able to detect select onchange i have also tried "jQuery get value of select onChange" but it is also not working in my case!!
My problem is
How to detect select on Change in a row cell as i have to update that changed data in database?
thanks in advance!!!!!
Upvotes: 1
Views: 3332
Reputation: 19066
I believe this will get everything you'll need for your database (value selected, cell and row it was selected in)... something like:
$("td select").on("change", function() {
var value = this.value;
var $cell = $(this).parent();
var $row = $cell.parent();
alert("Selected ["+value+"] in cell ["+$cell.index()+"] of row ["+$row.index()+"]");
});
Upvotes: 2
Reputation: 1803
$(document).on('change','td',function(){
//Do your abacadabra!
});
Upvotes: 0