Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts

    Help on Real time sales tax calculation

    I would like a script that would calculate sales tax automatically (without pressing any 'calculate' button) when a user clicks on a checkbox for california resident. That script would add the sales tax to subtotal to generate Grand Total. Thank you.

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Thanked 0 Times in 0 Posts
    Well, if you don't wana have a button, one way is to check if your check box is checked by a recursive function that is run in body tag. I have something that does the similar concept below:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <script language="JavaScript">
    flag = "U";
    before = after = 0;
    function dosth()
    if ( flag == "U" )
    document.nothing.AText.value = document.nothing.AText.value.toUpperCase();
    document.nothing.AText.value = document.nothing.AText.value.toLowerCase();
    function repeating()
    after = document.nothing.AText.value.length;
    if ( after != before )
    window.setTimeout("repeating()", 100);

    <body onload="repeating()">
    <form name="nothing">
    <input type="Text" size="40" name="AText">
    <input type="Reset">
    <input type="Radio" name="case" onclick="flag = 'U';" checked> Upper Case
    <input type="Radio" name="case" onclick="flag = 'L';"> Lower Case


    In each .1 second it checks which of the radio buttons are selected, then it converts the text based on their value ( If uppercase, everything would be wirtten in uppercase & vice versa). The repeating() function that's our background recursive function is working fine and checking those two radio buttons, I think you can change the code to fit your situation!


    Posting Permissions

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