显示dropdownlist项取决于使用javascript的另一个dropdownlist项
我想显示一个dropdownlistname子类别项,该子类别项依赖于另一个dropdownlistproblem类型项 问题类型:从问题类型中选择一种:行问题、服务问题、, 设备问题和账单问题 子类别: 线路问题–线路噪音、呼叫干扰、线路损坏 服务问题–供应商的重大服务中断 设备问题-噪音大、无拨号音、设备损坏 账单问题–账单支付未更新,账单错误 这是我的密码显示dropdownlist项取决于使用javascript的另一个dropdownlist项,javascript,html,Javascript,Html,我想显示一个dropdownlistname子类别项,该子类别项依赖于另一个dropdownlistproblem类型项 问题类型:从问题类型中选择一种:行问题、服务问题、, 设备问题和账单问题 子类别: 线路问题–线路噪音、呼叫干扰、线路损坏 服务问题–供应商的重大服务中断 设备问题-噪音大、无拨号音、设备损坏 账单问题–账单支付未更新,账单错误 这是我的密码 <html> <head> <meta http-equiv="Content-Type" co
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
window.onload = function addList(){
int i;
var sub = document.forms["raiseNewFault2"]["sub_category"];
var main = document.forms["raiseNewFault2"]["problem_type"].value;
var str1 = new Array("Noisy Line", "Call Interference", "Line damage");
var str2 = new Array("Major service outage at Provider");
var str3 = new Array("Noisy", "No Dial Tone", "Damaged Equipment");
var str4 = new Array("Billing paid not updated", "Wrong Billing");
if(main.equals("Line issue")){
for(i=0;i<=2;i++){
var option = document.createElement('option');
option.text = option.value = str1[i];
}
}
else if(main.equals("Service issue")){
for(i=0;i<=0;i++){
var option = document.createElement('option');
option.text = option.value = str2[i];
}
}
else if(main.equals("Equipment issue")){
for(i=0;i<=2;i++){
var option = document.createElement('option');
option.text = option.value = str3[i];
}
}
else if(main.equals("Billing issue")){
for(i=0;i<=1;i++){
var option = document.createElement('option');
option.text = option.value = str4[i];
}
}
select.add(option);
}
</script>
<style type="text/css">
#raiseNewFault2Div
{
margin-top : 25px;
margin-left : 325px;
height : 500px;
width : 600px;
background-color : #FFDA91;
border : ridge;
border-width : "3px"
}
</style>
</head>
<body onload="addList()">
<div id="raiseNewFault2Div">
<center>
<form name="raiseNewFault2" action="Controller" method="post">
<br/><br/>
<font size="3" color="#006E25">Problem type :
</font>
<select name="problem_type">
<option value="Line issue" selected>Line issue</option>
<option value="Service issue">Service issue</option>
<option value="Equipment issue">Equipment issue</option>
<option value="Billing issue">Billing issue</option>
</select>
<br/><br/><font size="3" color="#006E25">Sub Category :
</font>
<select name="sub_category"></select>
</from></center> </div></body></html>
最简单的方法是检查用户在第一个列表中选择了什么,然后使用javascript替换整个第二个列表:-
document.getElementByIdput此处包含列表的div的id。innerHTML=将要替换为旧列表的列表放在此处 我可以简单地用代码来回答,但这个网站并不适合它 您可能需要检查以下内容: 希望有帮助