[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Checkout.html java script Mod. for check_tax function.
First off let me start by saying that I am NOT a java script guru, expert
or even amateur for that matter so if you have any questions, sorry I
probably can't help much.
Anyways on to what I did. This is for all of us using the foundation
demo. I didn't like the fact that the script would only re-submit the page
when you changed to a State that had sales tax but not when you changed
from a taxable state to a non-taxable state it would not re-submit to
remove the taxes. Of course I didn't want the form to re-submit EVERY time
that someone changed states. Well anyway enough rambling here comes the
code with ******** NEW AREA ******** and ******** END NEW AREA ********.
for the things that I added.
PS The [if !value verified] was added by Lyn of Zolotek.net in relation
with another project, so you can leave it and it's corresponding [/if] at
the end out.
Any Java Guru's, Experts, (or even amateur's) out there that see any bugs
in this script please email me to let me know.
<SCRIPT> // JavaScript Form Validation Demo // by Paul Colton
******** NEW AREA *******
[if !value verified]
function old_state(obj) {
if (obj.type=="select-one") {
if (obj.options.length > 0) {
for (var i=0; i<obj.options.length; i++) {
if (obj.options[i].defaultSelected) {
return obj.options[i].value;
}
}
}
return "";
}
}
******** END NEW AREA *******
function check_tax(form) {
// Make sure the email field is not blank
var foundState = false;
var ch = form.state.value;
ch = ch.toUpperCase();
[loop list="__TAXAREA__"]
if(ch == "[loop-code]") {
form.submit();
alert("You will be charged [currency][fly-tax [loop-code]][/currency] sales
tax\nsince you are shipping to [loop-code]. This form should automaticaly
recalculate to include tax.");
foundState = true;
}
[/loop]
******** NEW AREA *******
var so = old_state(form.state);
so = so.toUpperCase();
[loop list="__TAXAREA__"]
if(so == "[loop-code]") {
form.submit();
alert("You have changed from a taxable state to a non-taxable state. The
form will be re-submitted to remove the current tax amount.");
foundState = true;
}
[/loop]
******** END NEW AREA *******
return foundState;
}
[/if]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Douglas K. Manning
Discount Computers, Inc.
6524 S. Tamiami Trail
Sarasota, FL. 34231
(941) 925-2215
http://www.cableguyusa.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~