我正在尝试使用用户表单建立一个小型网站。用户可以在四个字段中选择选项,并根据用户输入根据他/她的选择转到不同的结果页面。
<html>
<head>
<script language="JavaScript">
function testSelect (form) {
Item1 = form.location.selectedIndex;
Item2 = form.type.selectedIndex;
Item3 = form.bedrooms.selectedIndex;
Item4 = form.pricerange.selectedIndex;
Result1 = form.location.options[Item1].text;
Result2 = form.type.options[Item2].text;
Result3 = form.bedrooms.options[Item3].text;
Result4 = form.pricerange.options[Item4].text;
var input = Result1 +" "+ Result2 +" "+ Result3 +" "+ Result4;
if (input = "Town A Villa Two bedrooms 120.000 to 180.000 €") {
window.location.href = "http://www.google.com";
}
}
</script>
</head>
<body>
<form name="myform" action="" method="GET">
<input type="button" namelijktton" value="Search" onClick="testSelect(this.form)">
<select name="location">
<option disabled="disabled" selected="selected">Please select a location</option>
<option>Town A</option>
<option>Town B</option>
</select>
<select name="type">
<option disabled="disabled" selected="selected">Please select a type</option>
<option>Villa</option>
<option>Apartment</option>
</select>
<select name="bedrooms">
<option disabled="disabled" selected="selected">Please select number of bedrooms</option>
<option>Two bedrooms</option>
<option>Three bedrooms</option>
</select>
<select name="pricerange">
<option disabled="disabled" selected="selected">Please select a price range</option>
<option>120.000 to 180.000 €</option>
<option>180.000 to 250.000 €</option>
</select>
</form>
</body>
</html>
当条件“Town A Villa Two bedroom 120.000 to 180.000€”满足条件时,我可以让脚本工作,它将我带到Google页面,我将其用作测试。但我需要根据不同的选择加载其他页面。我应该如何从那里获取它,例如使用if elseif语句?