Why this script does not work with Netscape 7.2?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zaw

    #1

    Why this script does not work with Netscape 7.2?

    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(fo rm) {
    s_titleIndex = document.getEle mentById("s_tit le").selectedIn dex;
    s_firstname = document.getEle mentById("s_fir stname").value;
    s_lastname = document.getEle mentById("s_las tname").value;
    s_address = document.getEle mentById("s_add ress").value;
    s_address_2 = document.getEle mentById("s_add ress_2").value;
    s_city = document.getEle mentById("s_cit y").value;
    s_zipcode = document.getEle mentById("s_zip code").value;
    s_stateIndex = document.getEle mentById("_s_st ate").selectedI ndex;
    s_countryIndex = document.getEle mentById("s_cou ntry").selected Index;
    s_state = document.getEle mentById("_s_st ate").value;
    }

    function CopyBill(form) {
    if (form.copybill. checked) {
    SaveShipInfo(fo rm);
    document.getEle mentById("s_tit le").selectedIn dex =
    document.getEle mentById("title ").selectedInde x;
    document.getEle mentById("s_fir stname").value =
    document.getEle mentById("first name").value;
    document.getEle mentById("s_las tname").value =
    document.getEle mentById("lastn ame").value;
    document.getEle mentById("s_add ress").value =
    document.getEle mentById("b_add ress").value;
    document.getEle mentById("s_add ress_2").value =
    document.getEle mentById("b_add ress_2").value;
    document.getEle mentById("s_cit y").value =
    document.getEle mentById("b_cit y").value;
    document.getEle mentById("s_zip code").value =
    document.getEle mentById("b_zip code").value;
    document.getEle mentById("s_cou ntry").selected Index =
    document.getEle mentById("b_cou ntry").selected Index;
    change_states(d ocument.getElem entById('s_coun try'), 's_state',
    's_county', 'State', 'CA', '', '', '','','');
    document.getEle mentById("_s_st ate").selectedI ndex =
    document.getEle mentById("_b_st ate").selectedI ndex;
    document.getEle mentById("s_sta te").value =
    document.getEle mentById("_s_st ate").value;
    }
    else {
    document.getEle mentById("s_tit le").selectedIn dex = s_titleIndex;
    document.getEle mentById("s_fir stname").value = s_firstname;
    document.getEle mentById("s_las tname").value = s_lastname;
    document.getEle mentById("s_add ress").value = s_address;
    document.getEle mentById("s_add ress_2").value = s_address_2;
    document.getEle mentById("s_cit y").value = s_city;
    document.getEle mentById("s_zip code").value = s_zipcode;
    document.getEle mentById("s_cou ntry").selected Index = s_countryIndex;
    change_states(d ocument.getElem entById('s_coun try'), 's_state',
    's_county', 'State', 'CA', '', '', '','','');
    document.getEle mentById("_s_st ate").selectedI ndex = s_stateIndex;
    document.getEle mentById("s_sta te").value = s_state;
    }
    }

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

    Thank you
    Zaw
  • RobG

    #2
    Re: Why this script does not work with Netscape 7.2?

    zaw wrote:[color=blue]
    > 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.[/color]

    It would make life considerably easier if you reduced your code to a
    minimal example of the issue. Posting 50 lines of
    document.getEle mentById() 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.getEle mentById? If you
    also pass a reference to the billing form, you can get rid of it almost
    entirely, e.g.

    function CopyBill(form) {
    ...
    document.getEle mentById("s_tit le").selectedIn dex =
    document.getEle mentById("title ").selectedInde x;

    becomes

    function CopyBill(b,s) {
    s.elements("s_t itle").selected Index=
    b.elements("tit le").selectedIn dex;

    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><ti tle>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(fo rm) {
    s_titleIndex = document.getEle mentById("s_tit le").selectedIn dex;
    s_firstname = document.getEle mentById("s_fir stname").value;
    s_lastname = document.getEle mentById("s_las tname").value;
    s_address = document.getEle mentById("s_add ress").value;
    s_address_2 = document.getEle mentById("s_add ress_2").value;
    s_city = document.getEle mentById("s_cit y").value;
    s_zipcode = document.getEle mentById("s_zip code").value;
    s_stateIndex = document.getEle mentById("_s_st ate").selectedI ndex;
    s_countryIndex = document.getEle mentById("s_cou ntry").selected Index;
    s_state = document.getEle mentById("_s_st ate").value;
    }

    function CopyBill(form) {
    if (form.copybill. checked) {
    SaveShipInfo(fo rm);
    document.getEle mentById("s_tit le").selectedIn dex =
    document.getEle mentById("title ").selectedInde x;
    document.getEle mentById("s_fir stname").value =
    document.getEle mentById("first name").value;
    document.getEle mentById("s_las tname").value =
    document.getEle mentById("lastn ame").value;
    document.getEle mentById("s_add ress").value =
    document.getEle mentById("b_add ress").value;
    document.getEle mentById("s_add ress_2").value =
    document.getEle mentById("b_add ress_2").value;
    document.getEle mentById("s_cit y").value =
    document.getEle mentById("b_cit y").value;
    document.getEle mentById("s_zip code").value =
    document.getEle mentById("b_zip code").value;
    document.getEle mentById("s_cou ntry").selected Index =
    document.getEle mentById("b_cou ntry").selected Index;
    /*
    change_states(d ocument.getElem entById('s_coun try'), 's_state',
    's_county', 'State', 'CA', '', '', '','','');
    */
    document.getEle mentById("_s_st ate").selectedI ndex =
    document.getEle mentById("_b_st ate").selectedI ndex;

    document.getEle mentById("s_sta te").value =
    document.getEle mentById("_s_st ate").value;

    }
    else {
    document.getEle mentById("s_tit le").selectedIn dex = s_titleIndex;
    document.getEle mentById("s_fir stname").value = s_firstname;
    document.getEle mentById("s_las tname").value = s_lastname;
    document.getEle mentById("s_add ress").value = s_address;
    document.getEle mentById("s_add ress_2").value = s_address_2;
    document.getEle mentById("s_cit y").value = s_city;
    document.getEle mentById("s_zip code").value = s_zipcode;
    document.getEle mentById("s_cou ntry").selected Index = s_countryIndex;
    /*
    change_states(d ocument.getElem entById('s_coun try'), 's_state',
    's_county', 'State', 'CA', '', '', '','','');
    */
    document.getEle mentById("_s_st ate").selectedI ndex = s_stateIndex;
    document.getEle mentById("s_sta te").value = s_state;
    }
    }
    </script>
    </head>
    <body style="font-family: sans-serif; font-size: 8pt;">

    <table><tr><t d>
    <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">Fi rst Name<br>
    <input type="text" size="20" name="lastname"
    id="lastname" value="Smith">L ast 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="Smithvil le">Address 2<br>
    <input type="text" size="20" name="b_city"
    id="b_city" value="Smithtow n">City<br>
    <input type="text" size="20" name="b_zipcode "
    id="b_zipcode" value="1234">Zi p/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">Flor ida</option>
    </select>State<br >
    <select name="b_country " id="b_country" >
    <option value="USA">Uni ted States of America</option>
    <option value="UK" selected>United Kingdom</option>
    <option value="AUS">Aus tralia</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(docume nt.getElementBy Id('billingform '));
    ">Copy billing to shipping</button>
    </td>
    <td>

    <p>Shipping Details</p>

    <form action="" id="shippingfor m">
    <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_firstna me"
    id="s_firstname ">First Name<br>
    <input type="text" size="20" name="s_lastnam e"
    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">Cit y<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">Texa s</option>
    <option value="FL">Flor ida</option>
    </select>State<br >
    <input type="text" name="s_state" id="s_state">St ate<br>

    <select name="s_country " id="s_country" >
    <option value="USA">Uni ted States of America</option>
    <option value="UK">Unit ed Kingdom</option>
    <option value="AUS">Aus tralia</option>
    </select>Country< br>
    <input type="reset">
    </form>

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

    </body>
    </html>


    --
    Rob

    Comment

    • zaw

      #3
      Re: Why this script does not work with Netscape 7.2?

      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 <rgqld@iinet.ne t.auau> wrote in message news:<BIwqd.896 $I52.38351@news .optus.net.au>. ..[color=blue]
      > zaw wrote:[color=green]
      > > 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.[/color]
      >
      > It would make life considerably easier if you reduced your code to a
      > minimal example of the issue. Posting 50 lines of
      > document.getEle mentById() 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.getEle mentById? If you
      > also pass a reference to the billing form, you can get rid of it almost
      > entirely, e.g.
      >
      > function CopyBill(form) {
      > ...
      > document.getEle mentById("s_tit le").selectedIn dex =
      > document.getEle mentById("title ").selectedInde x;
      >
      > becomes
      >
      > function CopyBill(b,s) {
      > s.elements("s_t itle").selected Index=
      > b.elements("tit le").selectedIn dex;
      >
      > 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><ti tle>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(fo rm) {
      > s_titleIndex = document.getEle mentById("s_tit le").selectedIn dex;
      > s_firstname = document.getEle mentById("s_fir stname").value;
      > s_lastname = document.getEle mentById("s_las tname").value;
      > s_address = document.getEle mentById("s_add ress").value;
      > s_address_2 = document.getEle mentById("s_add ress_2").value;
      > s_city = document.getEle mentById("s_cit y").value;
      > s_zipcode = document.getEle mentById("s_zip code").value;
      > s_stateIndex = document.getEle mentById("_s_st ate").selectedI ndex;
      > s_countryIndex = document.getEle mentById("s_cou ntry").selected Index;
      > s_state = document.getEle mentById("_s_st ate").value;
      > }
      >
      > function CopyBill(form) {
      > if (form.copybill. checked) {
      > SaveShipInfo(fo rm);
      > document.getEle mentById("s_tit le").selectedIn dex =
      > document.getEle mentById("title ").selectedInde x;
      > document.getEle mentById("s_fir stname").value =
      > document.getEle mentById("first name").value;
      > document.getEle mentById("s_las tname").value =
      > document.getEle mentById("lastn ame").value;
      > document.getEle mentById("s_add ress").value =
      > document.getEle mentById("b_add ress").value;
      > document.getEle mentById("s_add ress_2").value =
      > document.getEle mentById("b_add ress_2").value;
      > document.getEle mentById("s_cit y").value =
      > document.getEle mentById("b_cit y").value;
      > document.getEle mentById("s_zip code").value =
      > document.getEle mentById("b_zip code").value;
      > document.getEle mentById("s_cou ntry").selected Index =
      > document.getEle mentById("b_cou ntry").selected Index;
      > /*
      > change_states(d ocument.getElem entById('s_coun try'), 's_state',
      > 's_county', 'State', 'CA', '', '', '','','');
      > */
      > document.getEle mentById("_s_st ate").selectedI ndex =
      > document.getEle mentById("_b_st ate").selectedI ndex;
      >
      > document.getEle mentById("s_sta te").value =
      > document.getEle mentById("_s_st ate").value;
      >
      > }
      > else {
      > document.getEle mentById("s_tit le").selectedIn dex = s_titleIndex;
      > document.getEle mentById("s_fir stname").value = s_firstname;
      > document.getEle mentById("s_las tname").value = s_lastname;
      > document.getEle mentById("s_add ress").value = s_address;
      > document.getEle mentById("s_add ress_2").value = s_address_2;
      > document.getEle mentById("s_cit y").value = s_city;
      > document.getEle mentById("s_zip code").value = s_zipcode;
      > document.getEle mentById("s_cou ntry").selected Index = s_countryIndex;
      > /*
      > change_states(d ocument.getElem entById('s_coun try'), 's_state',
      > 's_county', 'State', 'CA', '', '', '','','');
      > */
      > document.getEle mentById("_s_st ate").selectedI ndex = s_stateIndex;
      > document.getEle mentById("s_sta te").value = s_state;
      > }
      > }
      > </script>
      > </head>
      > <body style="font-family: sans-serif; font-size: 8pt;">
      >
      > <table><tr><t d>
      > <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">Fi rst Name<br>
      > <input type="text" size="20" name="lastname"
      > id="lastname" value="Smith">L ast 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="Smithvil le">Address 2<br>
      > <input type="text" size="20" name="b_city"
      > id="b_city" value="Smithtow n">City<br>
      > <input type="text" size="20" name="b_zipcode "
      > id="b_zipcode" value="1234">Zi p/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">Flor ida</option>
      > </select>State<br >
      > <select name="b_country " id="b_country" >
      > <option value="USA">Uni ted States of America</option>
      > <option value="UK" selected>United Kingdom</option>
      > <option value="AUS">Aus tralia</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(docume nt.getElementBy Id('billingform '));
      > ">Copy billing to shipping</button>
      > </td>
      > <td>
      >
      > <p>Shipping Details</p>
      >
      > <form action="" id="shippingfor m">
      > <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_firstna me"
      > id="s_firstname ">First Name<br>
      > <input type="text" size="20" name="s_lastnam e"
      > 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">Cit y<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">Texa s</option>
      > <option value="FL">Flor ida</option>
      > </select>State<br >
      > <input type="text" name="s_state" id="s_state">St ate<br>
      >
      > <select name="s_country " id="s_country" >
      > <option value="USA">Uni ted States of America</option>
      > <option value="UK">Unit ed Kingdom</option>
      > <option value="AUS">Aus tralia</option>
      > </select>Country< br>
      > <input type="reset">
      > </form>
      >
      > </td></tr></table>
      >
      > </body>
      > </html>[/color]

      Comment

      • Andrew Thompson

        #4
        Re: Why this script does not work with Netscape 7.2?

        On 2 Dec 2004 12:10:53 -0800, zaw wrote:
        [color=blue]
        > ..I was been working on this script for three
        > days but I cannot find a bug.[/color]

        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#net iquette>

        --
        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

        Comment

        • RobG

          #5
          Re: Why this script does not work with Netscape 7.2?

          zaw wrote:[color=blue]
          > 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[/color]
          [...]

          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.getEle mentById('s_cou ntry')
          + '\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

          Comment

          • zaw

            #6
            Re: Why this script does not work with Netscape 7.2?

            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 <SeeMySites@www .invalid> wrote in message news:<3rkeguv3h g9m.14e518uvtto qi.dlg@40tude.n et>...[color=blue]
            > On 2 Dec 2004 12:10:53 -0800, zaw wrote:
            >[color=green]
            > > ..I was been working on this script for three
            > > days but I cannot find a bug.[/color]
            >
            > 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#net iquette>[/color]

            Comment

            Working...