通过下拉框的值来确定输入框是否可以为空的代码
通过下拉框的值来确定输入框是否可以为空的代码
发布时间:2016-12-30 来源:查字典编辑
摘要:有两个文件a.html和b.html,a.html即下面的代码,b.html只是为了验证通过时候一个跳转页面,不做任何代码编写因为a.htm...

有两个文件a.html和b.html,a.html 即下面的代码,b.html只是为了验证通过时候一个跳转页面,不做任何代码编写

因为a.html用的是相对路径,所以要想程序能正常运行,b.html文件必须和a.html放在同一个目录下。

复制代码 代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title> New Document </title>

<meta name="Generator" content="EditPlus">

<meta name="Author" content="">

<meta name="Keywords" content="">

<meta name="Description" content="">

</head>

<script type="text/javascript">

function verify(){

var isNeed=document.getElementById("isNeed").value;

if(isNeed==1){

var reason=document.getElementById("reason").value;

if(reason==""||reason==null){

alert("预占资源原因不能为空");

}else{

window.location.href("a.html");

}

}else{

window.location.href("b.html");

}

}

</script>

<body>

是否需要预占资源

<select id="isNeed">

<option value="1">是</option><>

<option value="0" selected>否</option>

</select>

<input type="text" id="reason"/>

<input type="button" value="提交"/>

</body>

</html>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类