Jump to content

12Strings

Members
  • Posts

    1
  • Joined

  • Last visited

12Strings's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I would like to add 2 fields (qty + unitprice) from dropdowns = "total", write "tax" and "total" + "tax" = "total". I'm thinking I shouldn't need all this code? I'm lost. Help? <input readonly name="Total" size="10" value="" maxlength="10" > <input name="subtotal" size="10" value="" maxlength="10" onchange="doTotal(this.form)"> <input name="tax" size="10" value="" maxlength="10" onchange="doTotal(this.form)"> <input name="grandtotal" size="10" value="" maxlength="10" onchange="doTotal(this.form)"> function do_subtotal(form) { var a = (form.unitprice.value != '') ? eval(form.unitprice.value) : 0; var b = (form.qty.value != '') ? eval(form.qty.value) : 0; var c = (form.tax.value != '') ? eval(form.tax.value) : 0; form.Total.value = a * b + c; } /* ------------------------------------- */ function do_tax(form) { var a = (form.tax.value != '') ? eval(form.tax.value) : 0; form.Total.value = 0; } /* ------------------------------------- */ function do_grandtotal(form) { var a = (form.subtotal.value != '') ? eval(form.unitprice.value) : 0; var b = (form.tax.value != '') ? eval(form.tax.value) : 0; form.Total.value = a + b; } HTMl code: <TABLE align=center bgColor=#ccffff border=0> <TBODY> <TR> <TD width="20" bgColor=#DBDB70><B>Product - Unit Price </TH> <TH align=middle width="5" bgColor=#DBDB70><B>Qty</TH> <TH align=middle width="10" bgColor=#DBDB70><B>tax</TH> <TH align=middle width="10" bgColor=#DBDB70><B>total</TH> </tr><tr> <TD align=middle width="20" bgColor=#DBDB70><SELECT name=unitprice> <OPTION class=highlight value="" selected>choose <OPTION class=highlight value="249.95">Violina Conversion - 249.95 <OPTION class=highlight value="327.95">Pipsqueek Conversion - 327.95 </OPTION></SELECT></td> <TD align=middle width="5" bgColor=#DBDB70><SELECT name=qty> <OPTION class=highlight value="" selected>choose <OPTION class=highlight value="1">1 <OPTION class=highlight value="2">2 </OPTION></SELECT></td> -------------------------------- <td><input type='text' size = 10 name="tax" value="Tax <?php echo( htmlspecialchars( $row['tax'] ) ); ?>" /></td> <td><input type='text' size = 10 name="total" value="Total <?php echo( htmlspecialchars( $row['total'] ) ); ?>" /></td> </tr><tr> <hr> <TD align=middle width="5" bgColor=#DBDB70>sel
×
×
  • Create New...