Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

need help w/js


  • Please log in to reply
No replies to this topic

#1 12Strings

12Strings

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:06:07 AM

Posted 17 December 2015 - 08:04 PM

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
    


BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users