我是Javascript的新手,我正在尝试调整一段代码,以便在从表单中选择结果后转到URL。用户选择长度,然后从宽度中选择,选择应该转到正确的页面。
我可以在我的代码中看到每个宽度变量的值都被发送到'alert',它将值发送到弹出消息但是我希望它转到我命名为的URL值。
这可能是一个超级简单的解决方案,但看了很多其他线程,我无法理解如何更改代码转到URL。
感谢您的帮助
<form name="kits">
<select name="length" size="7" onChange="updatewidth(this.selectedIndex)" style="width: 180px">
<option selected>Select Length</option>
<option value="600x600html">600mm</option>
<option value="800">800mm</option>
<option value="1000">1000mm</option>
<option value="1200">1200mm</option>
<option value="2400">2400mm</option>
<option value="3050">3050mm</option>
</select>
<select name="width" size="5" style="width: 180px" onClick="alert(this.options[this.options.selectedIndex].value)">
</select>
</form>
<script type="text/javascript">
var lengthlist=document.kits.length
var widthlist=document.kits.width
var width=new Array()
width[0]=""
width[1]=["600mm|600x600html", "900mm|600x900.html", "1200mm|600x1200.html"]
width[2]=["600mm|800x600.html", "900mm|800x900.html", "1200mm|800x1200.html"]
width[3]=["600mm|1000x600.html", "900mm|1000x900.html", "1200mm|1000x1200.html"]
width[4]=["600mm|1200x600.html", "900mm|1200x900.html", "1200mm|1200x1200.html", "1800mm|1200x1800.html", "2400mm|1200x2400.html"]
width[5]=["600mm|2400x600.html", "900mm|2400x900.html", "1200mm|2400x1200.html"]
width[6]=["1200mm|3050x1200.html", "1500mm|3050x1500.html"]
function updatewidth(selectedwidthgroup){
widthlist.options.length=0
if (selectedwidthgroup>0){
for (i=0; i<width[selectedwidthgroup].length; i++)
widthlist.options[widthlist.options.length]=new Option(width[selectedwidthgroup][i].split("|")[0], width[selectedwidthgroup][i].split("|")[1])
}
}
</script>