在javaScript里面怎么清空下拉框的值
展开全部
subcity = new Array(); //定义一个数组,存放所有区县信息<%'下面输出所有区县信息,其实利用ASP动态输出JavaScript代码,请注意和Select1.htm的内容比较Dim dbSet db=Server.CreateObject("ADODB.Connection")
strcon="dbq="&server.mappath("city.mdb")&";driver={microsoft access driver (*.mdb)}"
db.open strcon
Dim strSql,rs,I
strSql="Select * From cities"
Set rs=db.Execute(strSql)I=0Do While Not rs.Eof
Response.Write "subcity[" & I & "] = new Array(""" & rs("ProID") & """,""" & rs("CityName") & """,""" & rs("CityID") & """);" & Chr(10) '最后输出一个换行符I=I+1rs.MoveNextLoop%>//下面函数用来切换区县
function mychange(provalue) { //proValue参数传入客户选中的省份编号
document.myform.dropcity.length = 0; //将city下拉框先清空
document.myform.dropcity.options[0] = new Option('==请选择区县==','');//先添加第0行var i;for (i=0;i < subcity.length; i++) // subcity.length表示数组长度,为5{if (subcity[i][0] == provalue) //判断是否属于所选省份{//下面语句将在city下拉框最下边添加一个新项
document.myform.dropcity.options[document.myform.dropcity.length] = new Option(subcity[i][1],subcity[i][2]);}}}</script></head><body><form name="myform" method="post">
<select name="droppro" onChange="mychange(this.options[this.selectedIndex].value);">
<option value="">==请选择省份==</option><%'下面读取所有省份信息
strSql="Select * From provinces"
Set rs=db.Execute(strSql)
Do While Not rs.Eof
Response.Write "<option value='" & rs("ProID") & "'>" & rs("ProName") & "</option>"
<option value="">==请选择区县==</option></select></form></body></html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询