我正在尝试以相同的形式将数据库值从表单保存到文本框中。每当加载表单时都会加载这些值。我在下面写了一个示例代码。我有 5 行文本框。我编写了以下从数据库中获取值的代码。但是我的知识仅限于使用 JSP 或 JAVAScript 将这五行值获取到五行文本框。尝试在线搜索,但没有很好的相关答案。任何帮助将不胜感激。谢谢你。
<body>
<%
String processVal = "SELECT * FROM NETWORK_ACCESS WHERE PRD_ID=?";
PreparedStatement pst = conn.prepareStatement(processVal);
pst.setString(1, ProcID);
ResultSet rsProcess=pst.executeQuery();
while(rsProcess.next())
{
SIP=rs.getString(2);
DIP=rs.getString(3);
SP=rs.getString(4);
SD=rs.getString(5);
ED=rs.getString(6);
}
%>
<table>
<tr>
<th>Sl.No</th>
<th>SIP</th>
<th>DIP</th>
<th>SP</th>
<th>Start Date</th>
<th>END Date</th>
</tr>
<tr>
<td style="align:center"> 1 </td>
<td><input type="text" name="name" id="id" size="20"> </td>
<td><input type="text" name="name1" id="id1" size="20"> </td>
<td><input type="text" name="name2" id="id2" size="20"> </td>
<td><input type="text" name="name3" id="id3" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
<td><input type="text" name="name4" id="id4" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
</tr>
<tr>
<td style="align:center"> <label> 2 </label> </td>
<td><input type="text" name="name" id="id5" size="20"> </td>
<td><input type="text" name="name1" id="id6" size="20"> </td>
<td><input type="text" name="name2" id="id7" size="20"> </td>
<td><input type="text" name="name3" id="id8" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
<td><input type="text" name="name4" id="id9" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
</tr>
<tr>
<td> <label> 3 </label> </td>
<td><input type="text" name="name" id="id10" size="20"> </td>
<td><input type="text" name="name1" id="id11" size="20"> </td>
<td><input type="text" name="name2" id="id12" size="20"> </td>
<td><input type="text" name="name3" id="id13" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
<td><input type="text" name="name4" id="id14" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
</tr>
<tr>
<td> <label>4 </label> </td>
<td><input type="text" name="name" id="id15" size="20"> </td>
<td><input type="text" name="name1" id="id15" size="20"> </td>
<td><input type="text" name="name2" id="id16" size="20"> </td>
<td><input type="text" name="name3" id="id17" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
<td><input type="text" name="name4" id="id18" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
</tr>
<tr>
<td> <label>5 </label> </td>
<td><input type="text" name="name" id="id19" size="20"> </td>
<td><input type="text" name="name1" id="id20" size="20"> </td>
<td><input type="text" name="name2" id="id21" size="20"> </td>
<td><input type="text" name="name3" id="id22" size="15"> <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name3','MMddyyyy','dropdown',false,'12')" /></td>
<td><input type="text" name="name4" id="id23" size="15"><img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('name4','MMddyyyy','dropdown',false,'12')" /> </td>
</tr>
</table>