SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript not playing in NS <sob!>

    Hello all,

    A little brain-teaser for you:

    Can anyone tell me why this Javascript won't work in Netscape(6)?
    Changing either the number or the currency should change the total.

    I've done my best to incorporate lessons learned in other forums on SPF, but where it works luvverly in IE, NS is still not playing i.e. not changing the on-screen total value.

    Before anyone says that it's ugly anyway, I've just stripped the bits out of my HTML that are relevant to make it easier - I hope - to spot the problem

    Packet of smarties for the winner!


    Andy
    From the English nation to a US location.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Check for document.all in your source code. Also, innerHTML is not a standard method if that's being used.

    --Vinnie

  3. #3
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only mention of document.all in the source is in a comment. Do you know the standard method of grabbing innerHTML?

    Also, I suspect that it's the Switch statement that's at fault.


    Andy
    From the English nation to a US location.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,236
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    In your JS source, instead of this:
    Code:
     Sel_Option = document.getElementById(s).options[Sel_Ind].innerHTML;
    Use this:
    Code:
     Sel_Option = document.getElementById(s).options[Sel_Ind].text;
    That will grab the text between the <option> tags, which is what you really want, NOT html. That may be the reason your script is messing up in NS. Either way, using .text will work in both browsers, the innerHTML was probably just implemented differently by the two companies, since innerHTML is not standard ECMAScript and each browser mfg. has leeway in its implementation.

    Now where are my smarties?

    --Vinnie

  5. #5
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No smarties for you!

    Here is some HTML that I wrote as a demo for another thread on SPF. As you can see, changing the selection from the drop-downs changes the text below the box.

    Here is the same HTML except that I've done a search/replace on "innerHTML" changing it to "text".

    The text doesn't change even in IE now


    Andy
    From the English nation to a US location.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •