我的数据在"数据"变量我想显示点击编辑按钮的所有数据我的编辑按钮是另一个jsp.Data" data"变量来自数据库的两种情况(新条目和编辑)如何执行该任务PLZ帮助我。
<%
String [][] data=null; int i=0; int j=0;
String mode="";
if(request.getAttribute("advRemittanceData")!=null)
{
data=(String [][])request.getAttribute("advRemittanceData");
}
mode=(String)request.getAttribute("mode");
%>
<script>
var count = "0";
function addRow(in_tbl_name)
{
count = parseInt(count) + 1;
document.getElementById(in_tbl_name).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR");
var td1 = document.createElement("TD")
var table = document.getElementById(in_tbl_name);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
cell1.style.width = "4%";
var element1 = document.createElement("input");
element1.type = "checkbox";
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
cell2.style.width = "15%";
var element4 = document.createElement("select");
element4.style.width = "100%";
element4.setAttribute("id", "compCode_"+count);
element4.setAttribute("name", "compCode_");
element4.setAttribute("style", "width:200px");
element4.setAttribute("maxlength", "1000");
<% if(data!=null){
for(i=0;i==0;i++)
{
for(j=0;j<data[0].length;j++)
{%>
option= document.createElement('option');
option.text = '<%=data[i][j]%>';
option.value = '<%=data[i][j]%>';
element4.options.add(option);
<%}}
}%>
cell2.appendChild(element4);
var td2 = document.createElement("TD")
var id3="importar_"+count;
var strHtml3 = "<input type='text' maxlength='500' style='width:100%;' name='importar_' id='"+id3+"'/>";
td2.innerHTML = strHtml3;
var td3 = document.createElement("TD")
td3.style.width = "15%";
var id4="iec_"+count;
var strHtml4 = "<input type='text' maxlength='10' style='width:100%;' name='iec_' id='"+id4+"'/>";
td3.innerHTML = strHtml4;
var td4 = document.createElement("TD")
var id5="amount_"+count;
var strHtml5 = "<input type='text' maxlength='10' style='width:100%;'name='amount_' id='"+id5+"'/>";
td4.innerHTML = strHtml5;
var td5 = document.createElement("TD")
var id6="document_"+count;
var strHtml6 = "<input type='text' maxlength='10' style='width:100%;'name='document_' id='"+id6+"'/>";
td5.innerHTML = strHtml6;
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
<%
mycount=mycount+1;
%>
//tbody.appendChild(row);
}
function deleteRow(tableID) {
try
{
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}
</script>
<body>
<table align="left" >
<TR>
<TD>
<input type="button" id="firstaddrow" value="Add" onclick="addRow('tablebody')" tabindex="1"/>
<input type="button" id="seconddeleterow" value="Delete" onclick="deleteRow('tablebody')" tabindex="2"/>
</TD>
</TR>
</table>
<table border ="1" id="tablebody" cellpadding="1" align="center" width="160%" >
</table>
</body>