javascript - How to set id to a <tr> generated from a JSON response? -


i want set id's dynamically rows. have this:

function (json) {         (var ib = 0; ib < json.length; ib++) {             var tableib = document.getelementbyid("treatments");             var treatmentid = json[ib].id;             var rowib = tableib.insertrow(-1);             var cell1ib = rowib.insertcell(0);             var cell2ib = rowib.insertcell(1);             var cell3ib = rowib.insertcell(2);             var cell4ib = rowib.insertcell(3);             var cell5ib = rowib.insertcell(4);             var buttonid = json[ib].id;             cell1ib.innerhtml = json[ib].name;             cell2ib.innerhtml = json[ib].time;             cell3ib.innerhtml = json[ib].price + "kr";             cell4ib.innerhtml = json[ib].details;             cell5ib.innerhtml = "button";         }     }); 

the id want set json response , has variable buttonid. possible or should append each row this? :

$('#treatments').append("<tr><td>" + shopname + "</td><td>" + shoptime + "</td><td>" + shopprice + "</td><td>" + shopdetails + "</td><td><center>" + editshop + deleteshop + "</center></td></tr>");  

in alter string beeing appended.

htmltablerowelement elements, htmlelement elements, have id property, so:

rowib.id = buttonid; 

...will it.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -