javascript 下拉列表验证的问题
<scriptlanguage="javascript">functionadd(){if(document.all.selects.value==""||documen...
<script language="javascript">
function add()
{
if(document.all.selects.value==""||document.all.selects.value==null)
{
alert("请选择季节!");
return;
}
}
</script>
<table border="0" align="center">
<tr>
<td><label>
<select name="selects" id="selects" onChange="add()">
<option value="">--请选择季节--</option>
<option value="spring.html">春天</option>
<option value="summer.html">夏天</option>
<option value="autumn.html">秋天</option>
<option value="winter.html">冬天</option>
</select>
</label></td>
</tr>
</table>
我想实现如果选择了第一个,就提示选择季节。如果选择了其他,就跳转到相应的页面。
onchange="javascript:location=this.value" 展开
function add()
{
if(document.all.selects.value==""||document.all.selects.value==null)
{
alert("请选择季节!");
return;
}
}
</script>
<table border="0" align="center">
<tr>
<td><label>
<select name="selects" id="selects" onChange="add()">
<option value="">--请选择季节--</option>
<option value="spring.html">春天</option>
<option value="summer.html">夏天</option>
<option value="autumn.html">秋天</option>
<option value="winter.html">冬天</option>
</select>
</label></td>
</tr>
</table>
我想实现如果选择了第一个,就提示选择季节。如果选择了其他,就跳转到相应的页面。
onchange="javascript:location=this.value" 展开
1个回答
展开全部
<script language="javascript">
function add()
{
if(document.all.selects.value=="")
{
alert("请选择季节!");
return;
}
if(document.all.selects.value=="spring.html"){
window.location.replace("spring.html");
}
if(document.all.selects.value=="summer.html"){
window.location.replace("summer.html");
}
if(document.all.selects.value=="autumn.html"陆拿激){
window.location.replace("autumn.html");
}
if(document.all.selects.value=="winter.html"){
window.location.replace("winter.html");
}
}
</script>
<table border="0" align="center">
<tr>
<td><label>
<select name="selects" id="selects" onchange="javascript:location=this.value">
<option value="">--请选择季节--</option>
<option value="spring.html">春天</早袜option>
<option value="summer.html">夏天</option>
<option value="autumn.html">秋敏搭天</option>
<option value="winter.html">冬天</option>
</select>
</label></td>
</tr>
</table>
代码我给你写完了.
function add()
{
if(document.all.selects.value=="")
{
alert("请选择季节!");
return;
}
if(document.all.selects.value=="spring.html"){
window.location.replace("spring.html");
}
if(document.all.selects.value=="summer.html"){
window.location.replace("summer.html");
}
if(document.all.selects.value=="autumn.html"陆拿激){
window.location.replace("autumn.html");
}
if(document.all.selects.value=="winter.html"){
window.location.replace("winter.html");
}
}
</script>
<table border="0" align="center">
<tr>
<td><label>
<select name="selects" id="selects" onchange="javascript:location=this.value">
<option value="">--请选择季节--</option>
<option value="spring.html">春天</早袜option>
<option value="summer.html">夏天</option>
<option value="autumn.html">秋敏搭天</option>
<option value="winter.html">冬天</option>
</select>
</label></td>
</tr>
</table>
代码我给你写完了.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询