1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Rep Power

    Calculate Form field on the fly

    Wondering if you can help?

    I am working on a script that allows to introducing 3 fields quantity, price, discount (%), and I would like to display and store an automatic calculated field (Total) executing this operation:

    quantity * price - discount(%) = Total

    May you help me to code all operations in order to display (not to store) Total?

    Thank you very much in advance,

    This my code:

    ---dbase connect
    PHP Code:

    PHP Code:
    $query="insert into pm_productos value('$prod_nombreproducto','$prod_cantidad',

    Quantity: <input type="text" name="prod_cantidad" size="20">
    Price: <input type="text" name="prod_preciounitario" size="20">
    Discount (%):<input type="text" name="prod_descuento" size="20">
    Total:<input type="text" name="prod_totalproducto" size="20"></td>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Rep Power
    you are already DISPLAYING it
    Total:<input type="text" name="prod_totalproducto" size="20"></td>

    am not sure i follow?

    if you want run time changes then use JQUERY/AJAX.

IMN logo majestic logo threadwatch logo seochat tools logo