if function in Java

Discussion in 'Web Design & Coding' started by Goober, Nov 4, 2007.

  1. Goober

    Goober THQ's Jester Moderator

    Joined:
    Jul 26, 2004
    Messages:
    2,864
    Location:
    Colorado
    So what I would like to do is have the value in
    Code:
    <INPUT TYPE = Text NAME = taxes SIZE = 6 value ="">
    to display 0 when the check box is unchecked

    As of right now the checkbox (checked or unchecked) will update the total value, which it needs to do.

    Here is EVERYTHING because I'm not sure what you would like to look at.
    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript" src="script1.js"></SCRIPT>  
    <SCRIPT language = JavaScript>
    function calculate() {
    A = document.FrontPage_Form1.book_1.value
    B = document.FrontPage_Form1.book_2.value
    C = document.FrontPage_Form1.book_3.value
    A = Number(A)
    B = Number(B)
    C = Number(C)
    // Subtotal
    D = ((A * 25.99) + (B * 25.99) + (C * 25.99))
    document.FrontPage_Form1.subtotal.value = D
    // Shipping
    E = Math.ceil((A + B + C)/3)
    F = (E * 8.95)
    document.FrontPage_Form1.shipping.value = F
    // Colorado sales tax
    G = (D * .079)
    var num = G;
    var tax = num.toFixed(2);
    document.FrontPage_Form1.taxes.value = tax
    // Total
    H = (D + F)
    if (document.FrontPage_Form1.colo_sales_tax.checked)
    H = (H + G)
    var num = H;
    var result = num.toFixed(2);
    document.FrontPage_Form1.totals.value = result
    }
    </SCRIPT>
    </head>
    <body>
    <form method="POST" name="FrontPage_Form1" onSubmit="return FrontPage_Form1_Validator(this)" target="_self"><font size="2"> 
    <INPUT TYPE = Text NAME = book_1 SIZE = 2 value = ""> Book 1
    <p><INPUT TYPE = Text NAME = book_2 SIZE = 2 value = ""> Book 2</p>
    <p><INPUT TYPE = Text NAME = book_3 SIZE = 2 value = ""> Book 3</p>
    <p><INPUT TYPE = Text NAME = subtotal SIZE = 6 value =""> Subtotal</p>
    <p><INPUT TYPE = Text NAME = taxes SIZE = 6 value =""> <INPUT TYPE = Checkbox NAME = colo_sales_tax value = "">Colorado Residents Check This Box For State Taxes</p>
    <p><INPUT TYPE = Text NAME = shipping SIZE = 6 value =""> Shipping</p>
    <p><INPUT TYPE = Text NAME = totals SIZE = 6 value = "">
    <Input Type = Button NAME = Totals VALUE = "Total" onClick = calculate()></font></p>
    </form>
    </body>
    </html>
    Sorry I'm not a clean coder
     
    Goober, Nov 4, 2007
    #1
    1. Advertisements

  2. Goober

    Goober THQ's Jester Moderator

    Joined:
    Jul 26, 2004
    Messages:
    2,864
    Location:
    Colorado
    Update: I got it working, just needed to put the statement in a different place.
     
    Goober, Nov 6, 2007
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ncmike

    CD's won't function!

    ncmike, Jun 28, 2004, in forum: Hardware
    Replies:
    6
    Views:
    1,075
    Nickweb
    Jul 1, 2004
  2. Adi
    Replies:
    4
    Views:
    467
    James
    Sep 22, 2003
  3. Alex Quant

    USB2 function destroyed, but USB1 working?!

    Alex Quant, Jun 10, 2005, in forum: DIY Computers
    Replies:
    3
    Views:
    519
    Alex Quant
    Jun 16, 2005
  4. funfly3
    Replies:
    0
    Views:
    376
    funfly3
    May 12, 2007
  5. frffrf
    Replies:
    0
    Views:
    390
    frffrf
    May 12, 2007
  6. Michael Salem

    Re: Windows' Find File function

    Michael Salem, Jun 24, 2003, in forum: PC Technical Talk
    Replies:
    0
    Views:
    354
    Michael Salem
    Jun 24, 2003
  7. Jeffrey Kaplan

    iPod function: Return to track?

    Jeffrey Kaplan, Jul 28, 2008, in forum: iPhone
    Replies:
    5
    Views:
    371
    Jeffrey Kaplan
    Jul 31, 2008
  8. travis

    Bluetooth for ipod function

    travis, Mar 13, 2009, in forum: iPhone
    Replies:
    0
    Views:
    222
    travis
    Mar 13, 2009
Loading...