07-09-2002, 11:12 PM
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.
07-09-2002, 11:25 PM
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">
flag = "U";
before = after = 0;
if ( flag == "U" )
document.nothing.AText.value = document.nothing.AText.value.toUpperCase();
document.nothing.AText.value = document.nothing.AText.value.toLowerCase();
after = document.nothing.AText.value.length;
if ( after != before )
<input type="Text" size="40" name="AText">
<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!