1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Problem in Subtraction

Discussion in 'PHP' started by newphpcoder, Dec 9, 2010.

  1. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    this codes:
    HTML:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <script type= "text/javascript"> 
    function startCalc(){
      interval = setInterval("calc()",1);
        }
    function calc(){
        var qty = new Array(2);
        qty[0] = parseFloat(document.myform.inqty.value);
      qty[1] = parseFloat(document.myform.outqty.value);
      
    myqtyval = qty[0]-qty[1];
    document.myform.myqty.value = myqtyval;    
    }
     
    function stopCalc(){
      clearInterval(interval);
    }
    </script>
    </head>
    <body>
    <form name='myform' action='test.php' method='post'>
    Input<input type='text' name='inqty'  onFocus='startCalc();' onBlur='stopCalc();' />
    Output<input type='text' name='outqty'  onFocus='startCalc();' onBlur='stopCalc();' /><br/>
    myqty<input type='text' name='myqty' value=''  />
    <input type='submit' name='submit' value='save' />
     
     
    </form>
    </body>
    </html>
    
    has the concept of what i want that after i insert number in output the result was automatically appear in qty but the problem in this code it did not use on key enter and I don't know how can i put that code n my php file where I attach.
    I'm sorry, i do understand the concept but I don't know how can I code it and where i can put the codes.

    Thank you..
     

Share This Page