如何添加數據庫值到我的combox()在選定的索引更改事件另一個組合框在同一個jsp頁面 請幫忙快............ ..在jsp中動態添加值到組合框
這裏是我的代碼
<tr>
<td>Item</td>
<td>
<select name="cboItems" id="cboItems">
<option value="-1">--Select--</option>
<%
CommodityInfoActions comObj = new CommodityInfoActions(erpConn);
comObj.getAllRecords();
Iterator itr = comObj.ListOfObjects.iterator();
int i = 1;
while (itr.hasNext()) {
CommodityInfo newObj = (CommodityInfo) itr.next();
String item = newObj.getCommodityName();
long itemid = newObj.getId();
out.println("<option value='" + itemid + "' >" + item + "</option>");
i++;
}
%>
</select>
</td>
</tr>
<tr>
<td>Batch No. </td>
<td>
<select id="cboBatchNo">
<option>--select--</option>
<%
try {
if (Long.parseLong(request.getParameter("cboItems")) > -1) {
CommodityPriceActions comp = new CommodityPriceActions(erpConn);
comp.getBatchno(Long.parseLong(request.getParameter("cboItems")));
CommodityPrices comPrice = new CommodityPrices();
itr = comp.ListOfObjects.iterator();
i = 1;
while (itr.hasNext()) {
CommodityPrices newObj = (CommodityPrices) itr.next();
out.println("<option value='" + newObj.getId() + "'>" + newObj.getBatchNo() + "</option>");
}
}
} catch (Exception exc) {
}
%>
</select>
</td>
</tr>
我想根據在運行時cboItems選擇的選項OT改變cboBatchno的內容...
您可以將onchange事件添加到combobox1並通過ajax發送請求,並將成功數據從ajax填充到combobox2中。 –