i'm using javascript editable table in bootstrap. 3 of columns dictated dropdown values. when values "saved" converted proper text values, i'm having trouble keeping saved dropdown choices "default" when come edit.
for example: enter '3' in dropdown , save it. if want go , edit (likely field in table), dropdown once held 3 goes default of 1.
here's code edit:
function edit() { var par = $(this).parent().parent(); //tr var tddate = par.children("td:nth-child(1)"); var tdcellnum = par.children('td:nth-child(2)'); var tdbuttons = par.children("td:nth-child(3)"); tddate.html("<input type='date' id='txtdate' value='"+tddate.html()+"'/>"); tdcellnum.html("<select id='txtcellnum'><option value=1>1</option> <option value=2>2</option><option value=3>3</option></select>"); tdbuttons.html("<img src='save.png' class='btnsave'/>"); any idea on how value tdcellnum display default in dropdown?
i've tried setting value of select =tdcellnum , tdcellnum.val , using number convert object number.i've tried setting var=tdcellnum rest of variables, document.getelementbyid("tdcellnum").value=copyvalue.html(); along tdcellnum.val=copyvalue no avail.any ideas?? thanks!
better create element , append it. way can use .val() select option.
var sel = $("<select id='txtcellnum'><option value=1>1</option><option value=2>2</option><option value=3>3</option></select>"); sel.val(tdcellnum.text()); tdcellnum.empty().append(sel);
Comments
Post a Comment