When updating multiple fields using ajax, I retrieve a row from the database on my server, JSON encode the row, and send it as the xmlhttp.responseText.
The format of the response text is as follows:
{"JobCardNum":5063,"IssueTo":"MachineShop","Priority":"High" ...lots of data}
After parsing the response text in the browser, I start the process of updating values like this:
var obj = JSON.parse(info);
document.getElementById("JobCardNum").value = obj.JobCardNum;
document.getElementById("IssueTo").value = obj.IssueTo;
document.getElementById("MachineShop").value = obj.MachineShop;
....... lots of similar statements
Since the element id matches the column names, I wondered if there was a way to loop through my JavaScript object and set all the values. Any suggestions?