日期:2014-05-17  浏览次数:21113 次

这段JS代码为什么提示脚本错误!
要实现的功能就是   点击了相应的的radiobutton   边上的下拉菜单也马上显示对应的选项!

<html>
<script   language= "javascript "   type= "text/javascript ">
function   refesh()
{
if   document.form1.radiobutton.checked   =   true
{
  var   jmpURL=document.form1.radiobutton.checked.value   ;
  if(jmpURL!= ' ')   {window.location= '?level= '+jmpURL;}  
  }
}
</script>
<body>
<form   name= "form1 "   method= "post ">
    <input   type= "radio "   name= "radiobutton "   value= "1 "   onclick   =   "javascript:refesh() ">
    <input   type= "radio "   name= "radiobutton "   value= "2 "   onclick   =   "javascript:refesh() ">
    <input   type= "radio "   name= "radiobutton "   value= "3 "   onclick   =   "javascript:refesh() ">
<%
level   =   request.QueryString( "level ")
%>
    <select   name= "select1 ">
        <option   value= "1 "   <%if   request.QueryString( "level ")   =   1   then   response.Write( "selected ")%> > 1 </option>
        <option   value= "2 "   <%if   request.QueryString( "level ")   =   2   then   response.Write( "selected ")%> > 2 </option>
        <option   value= "3 "   <%if   request.QueryString( "level ")   =   3   then   response.Write( "selected ")%> > 3 </option>
    </select>
</form>
</body>
</html>

------解决方案--------------------
大意了. 不要if var jmpURL= event.srcElement.value; if(jmpURL!= ' ') {window.location= '?level= '+jmpURL;}
------解决方案--------------------
<html>
<script language= "javascript " type= "text/javascript ">
function refesh(radioValue)
{
document.form1.select1.selectedIndex = radioValue;
}
</script>
<body>
<form name= "form1 " method= "post ">
<input type= "radio " name= "radiobutton " value= "1 " onclick = "refesh(this.value) ">
<input type= "radio " name= "radiobutton " value= "2 " onclick = "refesh(this.value) ">
<input type= "radio " name= "radiobutton " value= "3 " onclick = "refesh(this.value) ">

<select name= "select1 ">
<option value= "1 "> 1 </option>
<option value= "2 "> 2 </option>
<option value= "3 "> 3 </option>
</select>
</form>
</body>
</html>