472,954 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,954 software developers and data experts.

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 1606
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Akbar | last post by:
Hey there, Big-time curiosity issue here... Here's the test code (it's not that long)... it's to display a large number of image links with captions, ideally pulled in from an external file...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
3
by: Ed Brandmark | last post by:
I have a tag of the form <SCRIPT LANGUAGE="JavaScript1.1" SRC="foo.js"..... and was wondering if this delays the loading of my page until that file foo.js downloads. It seems that if I place...
2
by: Matthew | last post by:
Is there a javascript or alternative default fill friendly way for counting down the remaining characters left in a form box?
9
by: ALuPin | last post by:
Hi newsgroup users, I have the following java-script: </SCRIPT> </head> <body text='' link='' vlink='' alink='' bgcolor='FFFFFF'> <p> <center><TABLE cellSpacing=1 cellPadding=1...
4
by: Wm | last post by:
I have a script that changes a main/enlarged image when you click on a thumbnail. It works fine in IE, but for some reason it won't do anything in Netscape 7.1. Does anyone know if this is a...
13
by: Yousuf Khan | last post by:
Hi, I have this pre-built JS routine that creates a text animation special-effect. The routine was included inside a freeware HTML editor, called AceHTML. The problem is that it seems to work only...
7
by: Russ | last post by:
Hi All, I have a problem getting the following simple example of "document.write" creating a script on the fly to work in all html browsers. It works in I.E., Firefox, and Netscape 7 above. It...
3
by: niconedz | last post by:
Hi The following code works fine in IE but not Firefox. It's a little script that zooms an image and resizes the window to fit. Can anybody tell me what's wrong? Thanks Nico == btw.....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.