<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> 

解决方案 »

  1.   


    好像不对啊,兄弟
    输入框怎么写?
    <input .....>
      

  2.   

    test:
    <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> 
      

  3.   

    lawrendc 非常感谢你回答我的问题,可我写了这个还是不行啊,打开这个页面就弹出个-72的警示框
    <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>
      

  4.   


    <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>
      

  5.   

    哈哈,就是这个效果,厉害~·最后个小问题,我想在弹出框加几个字:**不是36的倍数,建议输入 returnValue怎么加?
      

  6.   


    <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>
      

  7.   

    lawrendc  太谢谢你了,高手就是高手,马上给分,再次谢谢!!!
      

  8.   

    alert(num+"不是36的倍数,建议输入"+returnValue);