我想将我的下拉列表验证为当前的javascript函数。
Javascript
function theteam() {
document.add_team_frm.action = "team.php";
document.add_team_frm.submit();
}
HTML
<form name="add_team_frm" action="team.php" method="post">
<select name="team_name[]">
<option value="0">Select Team</option>
<option value="1">Team A</option>
<option value="2">Team B</option>
<option value="3">Team C</option>
</select>
<a href="javascript:theteam()">Submit Team</a>
</form>
我使用链接作为提交按钮。如果name="team_name[]"
theteam()
上向value = 0
添加验证?
让我知道。
答案 0 :(得分:3)
试试这个:
function theteam(){
//check select
if(document.getElementById('selectID').value == 'whatever'){
document.forms['add_team_frm'].submit();
}
else { /*select check failed*/ }
}