这是一个选择状态的简单脚本,然后根据所选的状态选择一个Region,然后单击转到该Web站点
它在IE中完美运行。
代码在http://goldcoast.info/Chat.php
我尝试过很多东西试试让它在Firefox中运行,症状是当你点击按钮时它不会进入选定的网站。
我如何在Firefox中使用它?
<script language='JavaScript'>
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Please Select State',' ');
}
if (chosen == "NSW") {
selbox.options[selbox.options.length] = new Option('Blue Mountains','bluemountains.info');
selbox.options[selbox.options.length] = new Option('Coffs Coast','coffscoast.info');
}
if (chosen == "QLD") {
selbox.options[selbox.options.length] = new Option('Cairns','cairns.info');
selbox.options[selbox.options.length] = new Option('The Gold Coast','goldcoast.info');
}
if (chosen == "VIC") {
selbox.options[selbox.options.length] = new Option('Geelong','geelong.info');
selbox.options[selbox.options.length] = new Option('Phillip Island','phillipisland.info');
}
}
</script>
<form name="myform"><div class="centre">
State<br>
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="NSW">New South Wales</option>
<option value="QLD">Queensland</option>
<option value="VIC">Victoria</option>
</select><br>Region<br>
<select name="opttwo" size="1">
<option value=" " selected="selected">Please Select State</option>
</select><br />
<input class="red" type="button" name="go" value="Go There"
onclick="window.location.href('http://' + document.myform.opttwo.options[document.myform.opttwo.selectedIndex].value + '/index.php');return false">
</div></form>
答案 0 :(得分:0)
<form name="myform">
var selbox = document.myform.opttwo;
我认为这不适用于Firefox。尝试使用ID:
<form id="myform">
var selbox = document.getElementById("myform").opttwo;
答案 1 :(得分:0)
萤火虫显示警告,关于布兰登所写的许多警告。它还说pfcClient is not defined
- 尝试解决这个问题。并从PHP脚本中删除所有这些警告。