0
<form id="send" action="doaddnewuser.jsp" method="post">
<div id="controls" style="background-color:#FFFFFF;height:500px;width:750px;float:left;">
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<%
String buffer = "<tr><td><label for=''" + "productid" + "''>Product ID *</label></td> <td><select name='" + "productid" + "'>";
try {
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/XE", "*****", "*****");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("Select * from product");
while (rs.next()) {
buffer = buffer + "<option value='" + rs.getString(1) + "'>" + rs.getString(1) + "</option>";
}
buffer = buffer + "</select> </td></tr>";
response.getWriter().println(buffer);
} catch (Exception e) {
System.out.println(e);
}
%>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="price">Price *</label></td>
<td><input type="text" name="price" value="" size="60"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="debitaccount">Debit Account *</label></td>
<td><input type="text" name="debitaccount" value="" size="25" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="creditaccount">Credit Account *</label>
<td><input type="text" name="creditaccount" value="" size="25" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="quantity">Quantity *</label></td>
<td><input type="text" name="quantity" value="1" size="25" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="transactiondate">Transaction Date *</label></td>
<td><input type="date" name="transactiondate" value="" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="totalprice">Total Price *</label></td>
<td><input type="text" name="totalprice" value="" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label for="vat" style="text-align:justify" >15% VAT</label></td>
<td><input type="text" name="vat" value="" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td>
<input id ="submit" type="submit" value="Save" name="submit" />
</td>
</tr>
</tbody>
</table>
</div>
</form>
以上是我的HTML和JSP代碼來構建銷售輸入形式 - 但作爲網頁運行,這是由JSP構造的產品ID字段進入到左上角,而不是 與其他控件一起顯示動態場與JSP和HTML
可以請你幫助我爲什麼它走開。
P.S.這個想法是填充數據庫中的product_id字段