我在html中有兩個下拉列表。這兩個下拉列表正在獲取數據MySQL第一下拉是「主機組」有像「Windows,Linux」的價值和第二下拉是「主機」有價值像「辦公室,家庭,sidearea,本地主機」如何根據以前的下拉值篩選後選擇html下拉值
基本上我想這樣做當我選擇「linux」是hostgroup combobox時,它將過濾「主機」下拉框並在「主機」下拉列表中僅顯示localhost,當我在主機組下拉列表中選擇「windows」時,它將過濾它並從主機下拉列表中刪除localhost
我的HTML填充下拉的代碼是,
html.append("<select id='hosts' name='hosts' style='width: 180px' onchange=\"document.forms['form1'].submit();\">>");
//if(rs != null)
//{
while(rshostgroup.next())
{
html.append("<option value='"+rshostgroup.getString(2)+"'>"+rshostgroup.getString(1)+"</option>");
//html.append("<option value='web'>web</option>");
}
//}
html.append("<select>");
html.append("</td>");
html.append("</tr>");
html.append("<tr>");
html.append("<td>");
html.append("Host");
html.append("</td>");
html.append("<td>");
html.append("<select id='hosts' name='hosts' style='width: 180px' onchange=\"document.forms['form1'].submit();\">>");
//if(rs != null)
//{
while(rshost.next())
{
html.append("<option value='"+rshost.getString(2)+"'>"+rshost.getString(1)+"</option>");
//html.append("<option value='web'>web</option>");
}
//}
html.append("<select>");
請不要混淆,什麼html.append是什麼,我是什麼s選項值來自
其實我正在使用字符串生成器追加我的字符串生成器HTML在文件並調用jsp中的類html附加方法。它工作正常,下拉的選項值從ResultSet rs and rshost
填充有來自mysql的數據。