<script >
function a(inum){
var num=Math.floor(inum/36);
if(!inum/36){
return }
else {
var inum1=inum%36;
if(inum1<18){
alert(num*36);
}else{
alert((num+1)*36);
}
}
}
a(32);
</script>
function a(inum){
var num=Math.floor(inum/36);
if(!inum/36){
return }
else {
var inum1=inum%36;
if(inum1<18){
alert(num*36);
}else{
alert((num+1)*36);
}
}
}
a(32);
</script>
好像不对啊,兄弟
输入框怎么写?
<input .....>
<script>
function check(num){
if(num%36==0||num==0)
return num;
else {
var i=Math.floor(num/36);if((num-i*36)>18)
return (i+1)*36;
else
return i*36;
}
}alert(check(-79));
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script>
function check(num){
if(num%36==0||num==0)
return num;
else {
var i=Math.floor(num/36);if((num-i*36)>18)
return (i+1)*36;
else
return i*36;
}
}alert(check(-79));
</script>
<body>
<form name="form1" method="post" action="">
<input type="text" name="num">
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script>
function check(input){
var num=parseInt(input.value);
var returnValue=0;
if(num%36==0||num==0)
return ;
else {
var i=Math.floor(num/36);if((num-i*36)>18)
returnValue=(i+1)*36;
else
returnValue=i*36;
alert(returnValue);
input.value=returnValue;
}
}</script>
<body>
<form name="form1" method="post" action="">
<input type="text" name="num" onchange='check(this)'>
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script>
function check(input){
var num=parseInt(input.value);
var returnValue=0;
if(num%36==0||num==0)
return ;
else {
var i=Math.floor(num/36);if((num-i*36)>18)
returnValue=(i+1)*36;
else
returnValue=i*36;
alert(num+"不是36的倍数,建议输入"+returnValue);
input.value=returnValue;
}
}</script>
<body>
<form name="form1" method="post" action="">
<input type="text" name="num" onchange='check(this)'>
<input type="submit" name="Submit" value="提交">
</form>
</body>
</html>