1

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!!!!!

Community
  • 1
  • 1
Dev
  • 2,268
  • 23
  • 45

2 Answers2

2

I believe this will get everything you'll need for your database (value selected, cell and row it was selected in)... something like:

JSFiddle

$("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()+"]");
});
Smern
  • 18,066
  • 21
  • 67
  • 87
0
$(document).on('change','td',function(){
  //Do your abacadabra!
});
Joakim M
  • 1,733
  • 2
  • 13
  • 29