lz估计要留级了,哈L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<input type="text" id="y_crs" value="50" />
<input type="text" id="y_xhs" value="60" />
<input type="text" id="t_zrs" value="200" />
</form> <script type="text/javascript">
<!--var zs = "100"; //从数据库中读出的一个值想传给js用
var crs = document.form1.y_crs.value;//表单一值
var xhs = document.form1.y_xhs.value;//表单二值
var jhrs = document.form1.t_zrs.value;//表单三值
// 如果是小数就用 parseFloat!
if (parseInt(crs)+parseInt(xhs)+parseInt(zs) > parseInt(jhrs))
{
alert("超过总数不能通过.");
//return false;
}
else
{
alert("ok");
}
//-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<input type="text" id="y_crs" value="50" />
<input type="text" id="y_xhs" value="60" />
<input type="text" id="t_zrs" value="200" />
</form> <script type="text/javascript">
<!--var zs = "100"; //从数据库中读出的一个值想传给js用
var crs = document.form1.y_crs.value;//表单一值
var xhs = document.form1.y_xhs.value;//表单二值
var jhrs = document.form1.t_zrs.value;//表单三值
// 如果是小数就用 parseFloat!
if (parseInt(crs)+parseInt(xhs)+parseInt(zs) > parseInt(jhrs))
{
alert("超过总数不能通过.");
//return false;
}
else
{
alert("ok");
}
//-->
</script>
</body>
</html>
function CheckForm()
{ var crs=document.form1.y_crs.value;
var xhs=document.form1.y_xhs.value;
var jhrs=document.form1.t_zrs.value;
var ydrs=<%=nYudingShu%>//我想把在asp里的变量nYudingShu传给js用 因为要加上这个值才可以结果又运行不了了! if (crs+xhs+ydrs >jhrs) {
alert("预定人数不能超过计划人数.");
document.form1.y_xhs.focus();
return false;
}
return true;
}
</script>学长再给看看吧 如何才能把asp的变量传给js用呢!
这样就可以了