点击按钮<input type="button" name="button" value="搜 索" class='input' onClick="i()">
实现function i()
{
判断下拉框year和month是否有值,有给变量i=0,没有给i=1
}
參考答案:把下面代码另存为.htm就可以咯。
====================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新概念</title>
<style type="text/css">
<!--
body {
background-color: #E4EEBA;
margin-left: 0px;
margin-right: 0px;
}
-->
</style>
<script language="javascript">
function $form(){
if(document.form1.year.value=="" || document.form1.year.value==null){
return 0;
}
if(document.form1.month.value=="" || document.form1.month.value==null){
return 0;
}
return 1;
}
function $i(){
var i;
i=$form();
if(i==0){
alert("请选择日期!");
return false;
}
if(i==1){
return true;
}
}
</script>
<form name="form1" method="post" action="" onSubmit="return $i()">
<select name="year" id="year">
<option value="">请选择</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
年
<select name="month" id="month">
<option value="">请选择</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
月
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>