The code:
function updateValues(res){
var rows=res.ROWCOUNT;
for (i=0;i<rows;i++){
var x='document.Eventform.txt_'+res.DATA.EVENT_LENDER_ID[i];
x.value=res.DATA.EVENT_DAYS[i];
}
}
res is a JSON object passed to the function and we need to dynamically build form fields names and assign values to these fields (the form field name that are dynamically build will exist in the form).