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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Calculated Field

    I have a form with 3 fields:

    <form>
    Purchase Price: <input type="text" name="purchasePrice" size="10">

    Sale Price: <input type="text" name="salePrice" size="10">

    Profit: <input type="text" name="profit" size="10">
    </form>

    I'd like the profit field to be automatically filled in once the salePrice field loses focus.

    Any help on this would be greatly appreciated.

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    This will do it
    Code:
    function profit(){
         pp = document.form[0].purchasePrice.value;
         sp = document.form[0].salePrice.value;
         profit = pp - sp;
         document.form[0].profit.value = profit;
    }


  •  

    Posting Permissions

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