js判断select是否选中
<selectid="shouji"name="sja"><optionvalue="0"selected="selected">月份</option><optionva...
<select id="shouji" name="sja">
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
</select>
<select id="shouji" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
怎么用JS判断这个select是否选中? 展开
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
</select>
<select id="shouji" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
怎么用JS判断这个select是否选中? 展开
1个回答
推荐于2017-09-09
展开全部
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="白菜编辑部">
<title>白菜编辑部</title>
<style>
</style>
<script type="text/javascript">
var test = function ()
{
alert (shouji1.value);
alert (shouji2.value);
}
</script>
</head>
<body>
<select id="shouji1" name="sja">
<option value="0" selected="selected">月份</option>
<option value="01">01</option>
<option value="02">02</option>
</select>
<select id="shouji2" name="sjb">
<option value="0" selected="selected">年份</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
<button onclick="test();">test</button>
</body>
</html>
追问
怎么提示未选中
追答
var test = function ()
{
if(shouji1.value==0)
alert ('你没有选中月份哦');
if(shouji2.value==0)
alert ('你没有选中年份哦');
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询