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,326
  • 24
  • 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,746
  • 21
  • 72
  • 90
0
$(document).on('change','td',function(){
  //Do your abacadabra!
});
Joakim M
  • 1,793
  • 2
  • 14
  • 29