Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts

    Problem in Subtraction

    Good day!

    I need to automatically subtract the input qty and output qty and the result should be appear in the text area of qty.

    the input qty and output qty depend on the operation name.

    i try this code:

    PHP Code:
    <?php
      
    include("config.php");
      
      
    $query "SELECT operation_name FROM clt_traceability WHERE operation_name = '01. Spreading'";
      
      
    $inqty $_POST['input_qty'];
      
    $outqty $_POST['output_qty'];
      
    $qty $_POST['variance_qty'];
      
      
    $qty $inqty $outqty;

      
    ?>
    <html>
    <body>
    Input<input type = 'text' name='inqty' id='inqty' />
    Output<input type = 'text' name='outqty' id='outqty' />
    Qty<input type = 'text' name='qty' id='qty' />
    </body>
    </hmtl>
    in this code when i enter input = 100 output= 50 and when I enter or I used tab no output in qty.

    Thank you..

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    your posts are wrong and you need an echo
    Last edited by seco; 12-09-2010 at 02:37 AM.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    713
    Thanks
    165
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by seco View Post
    your posts are wrong and you need an echo
    i revised my code:

    PHP Code:
    <?php
      
    include("config.php");
      
      
    $query "SELECT operation_name FROM clt_traceability WHERE operation_name = '01. Spreading'";
      
    $result mysql_query($query);
      
      if (
    mysql_fetch_row($result))
      {     
      
    $inqty $_POST['input_qty'];
      
    $outqty $_POST['output_qty'];
      
    $qty $_POST['variance_qty'];
      
      
    $qty $inqty $outqty;
      }
      
    ?>
    <html>
    <head>
     <script language="javascript">
        function handleEnter(e, nextfield)
            {
            var characterCode = (e && e.which)? e.which: e.keyCode;
            if(characterCode == 13)
                {
                document.getElementById(nextfield).focus();
                return false;
                } 
            else
                {
                return true;
                }
            }
        </script>
    </head>
    <body>
    <form action="qty.php" method="post" name="qty">
    <?php
    echo "Input:<input type='text' name='inqty' id='inqty'onkeypress='return handleEnter(event,\"outqty\");' /><br />";
    echo 
    "Output:<input type='text' name='inqty' id='outqty'onkeypress='return handleEnter(event,\"qty\");' /><br />";
    echo 
    "Qty:<input type='text' name='inqty' id='qty'onkeypress='return handleEnter(event,\"inqty\");' /><br />";
    ?>
    </form>
    </body>
    </hmtl>
    When i run my test webpage I input 100 in input and 50 in output qty using enter key after i input 100 in input text field the cursor was go to the output text field and when i press the enter theres no output in qty.

    I really want to know is how is possible or the code to for automatically that input and output would subtract and the result is appear in qty text field.

    Thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •