我有这个表单,现在需要在用户选择游戏类型和插槽后创建一个重定向,然后按下名为“buynow.png”的图像按钮。
如果用户选择“public”,他将被重定向到“www.domain.com/public.html”,否则如果它的“private”转到“www.domain.com/private.html”
这里是实际代码
<div>
<form name="f1">
<div>
<select name="server_type" onchange="change_selection()">
<option value="0" selected>Select</option>
<option value="1">Public</option>
<option value="2">Private</option>
</select>
</div>
<div>
<select name="server_slots">
<option value="-">-</option>
</select>
</div>
<div>
<a><img src="images/bBuyNow.png" border="0" /></a>
</div>
</form>
<script language="javascript" type="text/javascript">
var slots_1=new Array("10 Players","11 Players","12 Players")
var slots_2=new Array("10 Players","11 Players","12 Players")
function change_selection(){
var server_type
server_type = document.f1.server_type[document.f1.server_type.selectedIndex].value
if (server_type != 0) {
slots_selected=eval("slots_" + server_type)
cant_slots = slots_selected.length
document.f1.server_slots.length = cant_slots
for(i=0;i<cant_slots;i++){
document.f1.server_slots.options[i].value=slots_selected[i]
document.f1.server_slots.options[i].text=slots_selected[i]
}
}else{
document.f1.server_slots.length = 1
document.f1.server_slots.options[0].value = "-"
document.f1.server_slots.options[0].text = "-"
}
document.f1.server_slots.options[0].selected = true
}
</script>
</div>
提前致谢。