I have a table that has 4 columns and column 4 is a dropdown list.
I know how to set the value in a normal Select -- but NOT when it's a Table field.
var $td = $('#Tbl_LD tbody td');
var vtd;
var Fidx = 3;
var SelectVal = '2';
vtd = $td.eq((Fidx*4)+3);
vtd.val(SelectVal); // my attempt at setting the Table row 3 field 4 select option to 2 -- does not work
My attempt at setting the Table row 3 field 4 select option to 2 -- does not work
Thanks in advance for help
Variable name should be clear and human understandable. Now regarding your problem, better to do like this:
var rows = $('#Tbl_LD tbody tr');
var selectVal = '2';
var rows3 = rows.eq(2);
var row3col4 = row3.find('td').eq(3);
var selectEl = row3col4.find('select');
// or club all selector in single line
// selectEl = rows.eq(2).find('td').eq(3).find('select');
selectEl.val(SelectVal);