468,168 Members | 1,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,168 developers. It's quick & easy.

Why this script does not work with Netscape 7.2?

zaw
Hi I am working on implementing this script to shopping cart.
Basically, it copies fill the shipping address from billing
automatically. I believe one or more syntax is not netscape
compatible. Can anyone point out which one it is and how to make it
both netscape and MS browser compatible? I hope if I can make the
script compatible for those two at extreme, it will probably work with
most browser out there. As you would notice, this form also calls
another fundtion already implemented in the shopping cart. But that
function itself works on both browser.

-----Code begin here----------
var s_titleIndex = 0;
var s_firstname = "";
var s_lastname = "";
var s_address = "";
var s_address_2 = "";
var s_city = "";
var s_zipcode = "";
var s_stateIndex = 0;
var s_countryIndex = 0;
var s_state = 0;

function SaveShipInfo(form) {
s_titleIndex = document.getElementById("s_title").selectedIndex;
s_firstname = document.getElementById("s_firstname").value;
s_lastname = document.getElementById("s_lastname").value;
s_address = document.getElementById("s_address").value;
s_address_2 = document.getElementById("s_address_2").value;
s_city = document.getElementById("s_city").value;
s_zipcode = document.getElementById("s_zipcode").value;
s_stateIndex = document.getElementById("_s_state").selectedIndex;
s_countryIndex = document.getElementById("s_country").selectedIndex ;
s_state = document.getElementById("_s_state").value;
}

function CopyBill(form) {
if (form.copybill.checked) {
SaveShipInfo(form);
document.getElementById("s_title").selectedIndex =
document.getElementById("title").selectedIndex;
document.getElementById("s_firstname").value =
document.getElementById("firstname").value;
document.getElementById("s_lastname").value =
document.getElementById("lastname").value;
document.getElementById("s_address").value =
document.getElementById("b_address").value;
document.getElementById("s_address_2").value =
document.getElementById("b_address_2").value;
document.getElementById("s_city").value =
document.getElementById("b_city").value;
document.getElementById("s_zipcode").value =
document.getElementById("b_zipcode").value;
document.getElementById("s_country").selectedIndex =
document.getElementById("b_country").selectedIndex ;
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
document.getElementById("_s_state").selectedIndex =
document.getElementById("_b_state").selectedIndex;
document.getElementById("s_state").value =
document.getElementById("_s_state").value;
}
else {
document.getElementById("s_title").selectedIndex = s_titleIndex;
document.getElementById("s_firstname").value = s_firstname;
document.getElementById("s_lastname").value = s_lastname;
document.getElementById("s_address").value = s_address;
document.getElementById("s_address_2").value = s_address_2;
document.getElementById("s_city").value = s_city;
document.getElementById("s_zipcode").value = s_zipcode;
document.getElementById("s_country").selectedIndex = s_countryIndex;
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
document.getElementById("_s_state").selectedIndex = s_stateIndex;
document.getElementById("s_state").value = s_state;
}
}

----------code ends here----------------

Thank you
Zaw
Jul 23 '05 #1
5 1369
zaw wrote:
Hi I am working on implementing this script to shopping cart.
Basically, it copies fill the shipping address from billing
automatically. I believe one or more syntax is not netscape
compatible. Can anyone point out which one it is and how to make it
both netscape and MS browser compatible? I hope if I can make the
script compatible for those two at extreme, it will probably work with
most browser out there. As you would notice, this form also calls
another fundtion already implemented in the shopping cart. But that
function itself works on both browser.


It would make life considerably easier if you reduced your code to a
minimal example of the issue. Posting 50 lines of
document.getElementById() code means that to do anything useful,
someone must reverse engineer your HTML. The chances they will get it
the same as yours are pretty slim.

You also do not include the code for change_states(), a likely source
of error.

You pass as reference to the shipping details form when calling
CopyBill, so why not use it instead of document.getElementById? If you
also pass a reference to the billing form, you can get rid of it almost
entirely, e.g.

function CopyBill(form) {
...
document.getElementById("s_title").selectedIndex =
document.getElementById("title").selectedIndex;

becomes

function CopyBill(b,s) {
s.elements("s_title").selectedIndex=
b.elements("title").selectedIndex;

I reverse engineered the HTML and your code (sans change_states())
works fine in Netscape. So either I fixed the issues or they are in
the HTML.

As a rule, if you develop using Netscape/Firefox and use IE for testing,
you will have fewer issues with accessing the document - but like all
rules, it's made to be broken. Slabs of code below...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Copy form</title>
<script>
var s_titleIndex = 0;
var s_firstname = "";
var s_lastname = "";
var s_address = "";
var s_address_2 = "";
var s_city = "";
var s_zipcode = "";
var s_stateIndex = 0;
var s_countryIndex = 0;
var s_state = 0;

function SaveShipInfo(form) {
s_titleIndex = document.getElementById("s_title").selectedIndex;
s_firstname = document.getElementById("s_firstname").value;
s_lastname = document.getElementById("s_lastname").value;
s_address = document.getElementById("s_address").value;
s_address_2 = document.getElementById("s_address_2").value;
s_city = document.getElementById("s_city").value;
s_zipcode = document.getElementById("s_zipcode").value;
s_stateIndex = document.getElementById("_s_state").selectedIndex;
s_countryIndex = document.getElementById("s_country").selectedIndex ;
s_state = document.getElementById("_s_state").value;
}

function CopyBill(form) {
if (form.copybill.checked) {
SaveShipInfo(form);
document.getElementById("s_title").selectedIndex =
document.getElementById("title").selectedIndex;
document.getElementById("s_firstname").value =
document.getElementById("firstname").value;
document.getElementById("s_lastname").value =
document.getElementById("lastname").value;
document.getElementById("s_address").value =
document.getElementById("b_address").value;
document.getElementById("s_address_2").value =
document.getElementById("b_address_2").value;
document.getElementById("s_city").value =
document.getElementById("b_city").value;
document.getElementById("s_zipcode").value =
document.getElementById("b_zipcode").value;
document.getElementById("s_country").selectedIndex =
document.getElementById("b_country").selectedIndex ;
/*
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
*/
document.getElementById("_s_state").selectedIndex =
document.getElementById("_b_state").selectedIndex;

document.getElementById("s_state").value =
document.getElementById("_s_state").value;

}
else {
document.getElementById("s_title").selectedIndex = s_titleIndex;
document.getElementById("s_firstname").value = s_firstname;
document.getElementById("s_lastname").value = s_lastname;
document.getElementById("s_address").value = s_address;
document.getElementById("s_address_2").value = s_address_2;
document.getElementById("s_city").value = s_city;
document.getElementById("s_zipcode").value = s_zipcode;
document.getElementById("s_country").selectedIndex = s_countryIndex;
/*
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
*/
document.getElementById("_s_state").selectedIndex = s_stateIndex;
document.getElementById("s_state").value = s_state;
}
}
</script>
</head>
<body style="font-family: sans-serif; font-size: 8pt;">

<table><tr><td>
<p>Billing Details</p>
<form action="" id="billingform">
<p>
<select name="title" id="title">
<option value="Mr">Mr</option>
<option value="Mrs" selected>Mrs</option>
<option value="Ms">Ms</option>
</select>Title<br>
<input type="text" size="20" name="firstname"
id="firstname" value="Fred">First Name<br>
<input type="text" size="20" name="lastname"
id="lastname" value="Smith">Last Name<br>
<input type="text" size="20" name="b_address"
id="b_address" value="12 Smith St">Address 1<br>
<input type="text" size="20" name="b_address_2"
id="b_address_2" value="Smithville">Address 2<br>
<input type="text" size="20" name="b_city"
id="b_city" value="Smithtown">City<br>
<input type="text" size="20" name="b_zipcode"
id="b_zipcode" value="1234">Zip/Post code<br>
<select name="_b_state" id="_b_state">
<option value="NY">New York</option>
<option value="TX" selected>Texas</option>
<option value="FL">Florida</option>
</select>State<br>
<select name="b_country" id="b_country">
<option value="USA">United States of America</option>
<option value="UK" selected>United Kingdom</option>
<option value="AUS">Australia</option>
</select>Country<br>
<input type="checkbox" name="copybill" id="copybill"
checked>Copy bill<br>
<input type="reset">
</form>

</td>
<td valign="bottom">
<button value="copy" onclick="
CopyBill(document.getElementById('billingform'));
">Copy billing to shipping</button>
</td>
<td>

<p>Shipping Details</p>

<form action="" id="shippingform">
<p>
<select name="s_title" id="s_title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>Title<br>
<input type="text" size="20" name="s_firstname"
id="s_firstname">First Name<br>
<input type="text" size="20" name="s_lastname"
id="s_lastname">Last Name<br>
<input type="text" size="20" name="s_address"
id="s_address">Address 1<br>
<input type="text" size="20" name="s_address_2"
id="s_address_2">Address 2<br>
<input type="text" size="20" name="s_city"
id="s_city">City<br>
<input type="text" size="20" name="s_zipcode"
id="s_zipcode">Zip/Post code<br>
<select name="_s_state" id="_s_state">
<option value="NY">New York</option>
<option value="TX">Texas</option>
<option value="FL">Florida</option>
</select>State<br>
<input type="text" name="s_state" id="s_state">State<br>

<select name="s_country" id="s_country">
<option value="USA">United States of America</option>
<option value="UK">United Kingdom</option>
<option value="AUS">Australia</option>
</select>Country<br>
<input type="reset">
</form>

</td></tr></table>

</body>
</html>
--
Rob
Jul 23 '05 #2
zaw
Hi Rob:
Thank you for your reply. I was been working on this script for three
days but I cannot find a bug. change_state function works fine in
netscape. I know this since it is part of shopping cart software and I
tested out in netscape without CopyBilling script. CopyBill script
works itself as well. But when I use them together, they do not work
in netscape but IE only. Since change_state script is very long (the
whole html age has over 1000 lines), I do not want to paste here. I am
trying to use Venkman Javascript debugger and cannot use it well yet.
If you like to debug it, I will send you in email. Otherwise, I just
want to say I appreciate your help, and hopefully I will find the bug
soon.

Zaw

RobG <rg***@iinet.net.auau> wrote in message news:<BI*****************@news.optus.net.au>...
zaw wrote:
Hi I am working on implementing this script to shopping cart.
Basically, it copies fill the shipping address from billing
automatically. I believe one or more syntax is not netscape
compatible. Can anyone point out which one it is and how to make it
both netscape and MS browser compatible? I hope if I can make the
script compatible for those two at extreme, it will probably work with
most browser out there. As you would notice, this form also calls
another fundtion already implemented in the shopping cart. But that
function itself works on both browser.


It would make life considerably easier if you reduced your code to a
minimal example of the issue. Posting 50 lines of
document.getElementById() code means that to do anything useful,
someone must reverse engineer your HTML. The chances they will get it
the same as yours are pretty slim.

You also do not include the code for change_states(), a likely source
of error.

You pass as reference to the shipping details form when calling
CopyBill, so why not use it instead of document.getElementById? If you
also pass a reference to the billing form, you can get rid of it almost
entirely, e.g.

function CopyBill(form) {
...
document.getElementById("s_title").selectedIndex =
document.getElementById("title").selectedIndex;

becomes

function CopyBill(b,s) {
s.elements("s_title").selectedIndex=
b.elements("title").selectedIndex;

I reverse engineered the HTML and your code (sans change_states())
works fine in Netscape. So either I fixed the issues or they are in
the HTML.

As a rule, if you develop using Netscape/Firefox and use IE for testing,
you will have fewer issues with accessing the document - but like all
rules, it's made to be broken. Slabs of code below...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Copy form</title>
<script>
var s_titleIndex = 0;
var s_firstname = "";
var s_lastname = "";
var s_address = "";
var s_address_2 = "";
var s_city = "";
var s_zipcode = "";
var s_stateIndex = 0;
var s_countryIndex = 0;
var s_state = 0;

function SaveShipInfo(form) {
s_titleIndex = document.getElementById("s_title").selectedIndex;
s_firstname = document.getElementById("s_firstname").value;
s_lastname = document.getElementById("s_lastname").value;
s_address = document.getElementById("s_address").value;
s_address_2 = document.getElementById("s_address_2").value;
s_city = document.getElementById("s_city").value;
s_zipcode = document.getElementById("s_zipcode").value;
s_stateIndex = document.getElementById("_s_state").selectedIndex;
s_countryIndex = document.getElementById("s_country").selectedIndex ;
s_state = document.getElementById("_s_state").value;
}

function CopyBill(form) {
if (form.copybill.checked) {
SaveShipInfo(form);
document.getElementById("s_title").selectedIndex =
document.getElementById("title").selectedIndex;
document.getElementById("s_firstname").value =
document.getElementById("firstname").value;
document.getElementById("s_lastname").value =
document.getElementById("lastname").value;
document.getElementById("s_address").value =
document.getElementById("b_address").value;
document.getElementById("s_address_2").value =
document.getElementById("b_address_2").value;
document.getElementById("s_city").value =
document.getElementById("b_city").value;
document.getElementById("s_zipcode").value =
document.getElementById("b_zipcode").value;
document.getElementById("s_country").selectedIndex =
document.getElementById("b_country").selectedIndex ;
/*
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
*/
document.getElementById("_s_state").selectedIndex =
document.getElementById("_b_state").selectedIndex;

document.getElementById("s_state").value =
document.getElementById("_s_state").value;

}
else {
document.getElementById("s_title").selectedIndex = s_titleIndex;
document.getElementById("s_firstname").value = s_firstname;
document.getElementById("s_lastname").value = s_lastname;
document.getElementById("s_address").value = s_address;
document.getElementById("s_address_2").value = s_address_2;
document.getElementById("s_city").value = s_city;
document.getElementById("s_zipcode").value = s_zipcode;
document.getElementById("s_country").selectedIndex = s_countryIndex;
/*
change_states(document.getElementById('s_country') , 's_state',
's_county', 'State', 'CA', '', '', '','','');
*/
document.getElementById("_s_state").selectedIndex = s_stateIndex;
document.getElementById("s_state").value = s_state;
}
}
</script>
</head>
<body style="font-family: sans-serif; font-size: 8pt;">

<table><tr><td>
<p>Billing Details</p>
<form action="" id="billingform">
<p>
<select name="title" id="title">
<option value="Mr">Mr</option>
<option value="Mrs" selected>Mrs</option>
<option value="Ms">Ms</option>
</select>Title<br>
<input type="text" size="20" name="firstname"
id="firstname" value="Fred">First Name<br>
<input type="text" size="20" name="lastname"
id="lastname" value="Smith">Last Name<br>
<input type="text" size="20" name="b_address"
id="b_address" value="12 Smith St">Address 1<br>
<input type="text" size="20" name="b_address_2"
id="b_address_2" value="Smithville">Address 2<br>
<input type="text" size="20" name="b_city"
id="b_city" value="Smithtown">City<br>
<input type="text" size="20" name="b_zipcode"
id="b_zipcode" value="1234">Zip/Post code<br>
<select name="_b_state" id="_b_state">
<option value="NY">New York</option>
<option value="TX" selected>Texas</option>
<option value="FL">Florida</option>
</select>State<br>
<select name="b_country" id="b_country">
<option value="USA">United States of America</option>
<option value="UK" selected>United Kingdom</option>
<option value="AUS">Australia</option>
</select>Country<br>
<input type="checkbox" name="copybill" id="copybill"
checked>Copy bill<br>
<input type="reset">
</form>

</td>
<td valign="bottom">
<button value="copy" onclick="
CopyBill(document.getElementById('billingform'));
">Copy billing to shipping</button>
</td>
<td>

<p>Shipping Details</p>

<form action="" id="shippingform">
<p>
<select name="s_title" id="s_title">
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
</select>Title<br>
<input type="text" size="20" name="s_firstname"
id="s_firstname">First Name<br>
<input type="text" size="20" name="s_lastname"
id="s_lastname">Last Name<br>
<input type="text" size="20" name="s_address"
id="s_address">Address 1<br>
<input type="text" size="20" name="s_address_2"
id="s_address_2">Address 2<br>
<input type="text" size="20" name="s_city"
id="s_city">City<br>
<input type="text" size="20" name="s_zipcode"
id="s_zipcode">Zip/Post code<br>
<select name="_s_state" id="_s_state">
<option value="NY">New York</option>
<option value="TX">Texas</option>
<option value="FL">Florida</option>
</select>State<br>
<input type="text" name="s_state" id="s_state">State<br>

<select name="s_country" id="s_country">
<option value="USA">United States of America</option>
<option value="UK">United Kingdom</option>
<option value="AUS">Australia</option>
</select>Country<br>
<input type="reset">
</form>

</td></tr></table>

</body>
</html>

Jul 23 '05 #3
On 2 Dec 2004 12:10:53 -0800, zaw wrote:
..I was been working on this script for three
days but I cannot find a bug.


Can you perhaps work on finding your delete key[1] zaw?
There was no need to repost over 200 lines of earlier conversation[2]
simply to report that you cannot get it to work.

[1] <http://www.physci.org/kbd.jsp?key=del>
[2] <http://www.physci.org/codes/javafaq.jsp#netiquette>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Jul 23 '05 #4
zaw wrote:
Hi Rob:
Thank you for your reply. I was been working on this script for three
days but I cannot find a bug. change_state function works fine in
netscape. I know this since it is part of shopping cart software and I
tested out in netscape without CopyBilling script. CopyBill script
works itself as well. But when I use them together, they do not work
in netscape but IE only. Since change_state script is very long (the

[...]

Then clearly the issue is either:

1. What you are passing to change_states(),

or

2. whatever change_states() is doing.

I can only guess that when the user selects a country, change_states()
builds a new option list with the states for that country. Is that
correct?

I would reduce the code in the page to be just the fields & values
required for change_states(), then put alerts either side (at each step
of the code if necessary) and test the values of everything before and
after going to change_states().

i.e. do something like:

var msg = 's_country is: ' + document.getElementById('s_country')
+ '\ns_state is: ' + s_state
+ '\ns_county is: ' + s_county
+ '\nState is: ' + State
+ '\nCA is: ' + CA
...

alert(msg);

directly before calling change_states(). Then the first line of
change_states() should do the same thing to see what it actually got.

I would do the same to change_states - implement an absolutely minimum
version that had say 2 countries with 2 states each. If you like,
email me the source to change_states() (remove the second 'au').
Cheers.
--
Rob
Jul 23 '05 #5
zaw
I just hit "post reply" and did not think it would harm anyone. Looks
like you had to spend a little extra pennies downloading this post. Do
not worry I solved the problem finally. Won't post it again.

Andrew Thompson <Se********@www.invalid> wrote in message news:<3r****************************@40tude.net>.. .
On 2 Dec 2004 12:10:53 -0800, zaw wrote:
..I was been working on this script for three
days but I cannot find a bug.


Can you perhaps work on finding your delete key[1] zaw?
There was no need to repost over 200 lines of earlier conversation[2]
simply to report that you cannot get it to work.

[1] <http://www.physci.org/kbd.jsp?key=del>
[2] <http://www.physci.org/codes/javafaq.jsp#netiquette>

Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Johnny Knoxville | last post: by
3 posts views Thread by Ed Brandmark | last post: by
9 posts views Thread by ALuPin | last post: by
4 posts views Thread by Wm | last post: by
13 posts views Thread by Yousuf Khan | last post: by
7 posts views Thread by Russ | last post: by
3 posts views Thread by niconedz | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.