The following code should do what you want
function updateValues(res) {
var rows = res.ROWCOUNT;
var form = document.forms['EventForm'];
for (var i=0; i<rows; i++) {
form.elements['txt_' + res.DATA.EVENT_LENDER_ID[i]].value = res.DATA.EVENT_DAYS[i];
}
}
However, if you can change the layout of the JSON object to something else you might be able to make that code a little bit cleaner:
function updateValues(res) {
var form = document.forms['EventForm'];
for (var name in res) {
form.elements['txt_' + name].value = res[name];
}
}
Even better would be if the form fields had their id attribute set to the name contained in the JSON object. In that case the following would work (in conjunction with changing the JSON object):
function updateValues(res) {
for (name in res) {
document.getElementById(name).value = res[name];
}
}
Bryan Kyle
2009-11-17 00:28:33