Web Analytics Made Easy -
StatCounter Help on Real time sales tax calculation - CodingForum

Announcement

Collapse
No announcement yet.

Help on Real time sales tax calculation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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">

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

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


    </body>
    </html>


    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!

    Comment

    Working...
    X