www.webdeveloper.com
Results 1 to 8 of 8

Thread: GetElementByID in Internet Explorer

  1. #1
    Join Date
    Jul 2009
    Posts
    4

    GetElementByID in Internet Explorer

    Hello,

    First im not a javascript coder and work normally in PHP. I know basic javascript so that ive produced on my site may not be the best way of achieving what i want.

    I have http://www.footballprogrammecentre.c...ales.php?id=16 which is selling items. Its using a 3rd party cart to store the products in and im manifulating it using javascript to look after by shipping cost needs as it doesnt cater for this in the php code.

    If you click the little basket with the green arrow it adds a product to your cart, in firefox the page then reloads (forced by javascript) to caclulate the shipping cost. However in IE nothing happens... I think because of an error which the javascript has created on the page... possibly as the GetElementById function is trying to access a tag which isnt on my page initially and only exists in the cart page which isnt loaded until an item is added to cart?

    Can anyone help me out please?

    Thank you very much
    Craig

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380
    Just a query:
    Be sure you are using 'getElementById' and not 'GetElementById'.

    Also, it does not seem to like line 398 of your code
    as I'm getting error reports that 'document.getElementById('ej_ejc_frm_1") is null
    usually indicating it does not exist or that you have some sort of typo error.
    Last edited by JMRKER; 07-13-2009 at 03:28 PM. Reason: Additional error

  3. #3
    Join Date
    Jul 2009
    Posts
    4
    Hi,
    Thanks for your reply, yes i am using getElementById... im just not too used to JS syntax which is why i used a capital G in my post

  4. #4
    Join Date
    Jul 2009
    Posts
    4
    Quote Originally Posted by JMRKER View Post
    Just a query:
    Be sure you are using 'getElementById' and not 'GetElementById'.

    Also, it does not seem to like line 398 of your code
    as I'm getting error reports that 'document.getElementById('ej_ejc_frm_1") is null
    usually indicating it does not exist or that you have some sort of typo error.

    Yes thats exactly my problem as this element only exists once the cart has been activated, however i do not know how to work around this

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380
    Can you create a place-holder element with that name/id until the real element is accessed?

  6. #6
    Join Date
    Sep 2008
    Posts
    408
    Add a boolean statement around it:

    Code:
    if(document.getElementById('ej_ejc_frm_1')) { /* do your stuff */ }
    else { /* do something else */ }
    Mullanaphy!
    http://www.mullanaphy.com/

    Unless code is provided or an exact example is requested I think I'm going to start using psuedo code from now on...

    Also, I freelance as well. Inquire within!

  7. #7
    Join Date
    Jul 2009
    Posts
    4
    Quote Originally Posted by Shorts View Post
    Add a boolean statement around it:

    Code:
    if(document.getElementById('ej_ejc_frm_1')) { /* do your stuff */ }
    else { /* do something else */ }

    Amen that man!! Now i just have a slightly differnet error further down the page (line 440, n is not defined).. Any advice please?

    Thank you so much so far!

  8. #8
    Join Date
    Sep 2008
    Posts
    408
    Haven't delved much into your source, but one of the array's is trying to read index N of an array that looks like it's being set depending on other aspects.

    Would say add an "n = 0;" right after "function disableQty()" and then find out why it's not being set.

    And this is all from a Tim :P
    Mullanaphy!
    http://www.mullanaphy.com/

    Unless code is provided or an exact example is requested I think I'm going to start using psuedo code from now on...

    Also, I freelance as well. Inquire within!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles