我的代码是这样的 -
<table border="0" cellspacing="2" cellpadding="2" width="99%" id="subAccTable">
<tr>
<h2>Sub Accounts</h2>
</tr>
<tr>
<th>action </th>
<th>account</th>
<th>homeDir</th>
<th>primaryGroup</th>
</tr>
<tr>
<td><input type="hidden" name="vtierId" value="<%=vtierId%>" /></td>
<td><input type="text" name="subAcc"
value="<%= (String)subAccountUtil.getSubAccountName().get(i) %>"/></td>
<td><input type="text" name="subHomeDir"
value="<%= (String)subAccountUtil.getSubAccountHomeDir().get(i) %>"/></td>
<td><input type="text" name="subPriGroup"
value="<%= (String)subAccountUtil.getSubAccountPrimaryGroup().get(i) %>" /></td>
<script>
var saveObj = new ajax();
form.action.value = "populate";
var queryString = "action="+form.action.value+"&vtierSelectedValue="+vtierSelectedValue+"&vtierSelectedName="+vtierSelectedName ;
saveObj.onCompletion = function() {
var obj = saveObj.response;
alert(obj);
var objArr = obj.split(",");
}
saveObj.form = form;
saveObj.requestFile = "account.do";
saveObj.runAJAX(queryString);
</script>
现在我想在这里使用数组objArr中的值填充表行,其中包含1234,〜,tedtds,tedtds等值。 如何将此数组中的值填充到表格行中的文本框中? 目前文本框从我不想要的scriptlet中获取值?
答案 0 :(得分:0)
你应该做的是循环遍历数组,我不太清楚如何安排objArr中的数据,但可以调整以下代码
var i = objArr.length, html=[], row, id,inputs ;
while (i--) {
row = objArr[i].split(";"); //supposing that each contains "id;val1;val2;val3"
id=row[0] //supposedly
inputs = $("#" + id + " input");
$(inputs[0]).val(row[1]);
$(inputs[1]).val(row[2]);
$(inputs[2]).val(row[3]);
}