I have a shopping cart that uses Javascript, and it works in MSIE,
Firefox, Netscape 8, but not Netscape 7.1. I urgently need to debug
the Netscape 7 behavior but don't have enough Javascript chops to do
it. I usually write Perl.
I'm hoping this is a quick question involving some known wrinkle in this
browser's JS handling. I don't need the code rewritten, just the clue
as to why these scripts don't work.
If it's not a quick question, the next best type of answer would be a
hint about how to debug Javascript in Netscape. Currently the scripts
fail silently and I don't know how to make them produce a useful error
message.
Now for the code. There are two functions. The first is called when
the form submits, and it fools with the fields before submitting to
the credit-card processor. It looks like this:
function preprocess () {
//strip end spaces from billing name
var str = mainform.GWNameOnCard.value.replace(/^[\s]+/,"");
str = str.replace(/[\s]+$/,"")
mainform.GWNameOnCard.value = str
//split billing name at last space
var i = str.lastIndexOf(' ');
if (i == -1)
{
mainform.GWBillingFirstName.value = " ";
mainform.GWBillingLastName.value = str;
} else
{
mainform.GWBillingFirstName.value = str.substring(0,i);
mainform.GWBillingLastName.value = str.substring(i + 1);
}
//concatenate billing address fields
mainform.GWBillingAddress.value = mainform.BillAddress.value;
if (mainform.BillAddress2.value.length > 0)
{
mainform.GWBillingAddress.value = mainform.BillAddress.value + ", "
+ mainform.BillAddress2.value;
}
//use NA for blank zip
mainform.GWBillingZip.value = (mainform.GWBillingZip.value == "" ?
"NA" : mainform.GWBillingZip.value);
}
The call looks like this:
<form name="mainform" method="POST" action="<<credit card URL>>"
onsubmit="preprocess();">
The other function copies shipping address fields into billing address fields:
function copybill () {
mainform.GWNameOnCard.value = mainform.ShipName.value;
mainform.BillAddress.value = mainform.ShipAddress.value;
mainform.BillAddress2.value = mainform.ShipAddress2.value;
mainform.GWBillingCity.value = mainform.ShipCity.value;
mainform.GWBillingZip.value = mainform.ShipZip.value;
mainform.GWBillingCountry.value = mainform.ShipCountry.value;
//copy state field
mainform.GWBillingState.selectedIndex = mainform.ShipState.selectedIndex +
(mainform.ShipState.selectedIndex < 4 ? 1 : 2);
mainform.GWBillingCountry.selectedIndex = 0;
}
and the call is like this:
<input type="button" value="Same as Shipping Address" onClick="copybill();">
Yes, Javascript is turned on in my Netscape 7.1. Yes, the form name and
form field names match. Everything works in MSIE and Firefox, these
scripts are handling live transactions and everyone but Netscape
users is doing fine. I've tried cutting copybill() back to a single
line with nothing in it but one form field assignment and it still
doesn't work.
Hope you can help -- thanks much for reading! |