87,989
社区成员
发帖
与我相关
我的任务
分享<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--<script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>-->
<body >
<form id="form1">
<select id="sel">
<option value="">--请选择--</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="button" value="click me" id="btn">
</form>
<script>
var value = '';
document.getElementById('sel').onchange = function(){
value = this[this.selectedIndex].value;
};
document.getElementById('btn').onclick = function(){
if(value){
document.getElementById('form1').submit();
}else{
alert('下拉框没有选择不能提交')
}
};
</script>
</body>
</html>
<html>
<head>
</head>
<body>
下拉框<select onchange="if(confirm('确认吗?'))alert('数据提交成功!');">
<option></option>
<option>1</option>
<option>2</option>
</select>
</body>
</html>