SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get this variable in to my code

    Hi,

    I need to build the property for a getElementById dynamically. Ive tried this:



    Code JavaScript:
     var elementID = 'bubbleMESSAGE' + userID;
     
       	 var bubble = document.getElementById(elementID);

    But it doesnt work....userID is a variable with a value assigned to it earlier in the script.....all i get when i run this code is bubble has no properties

    any ideas?

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't see anything wrong with the code you've posted. Is there definitely an element with the id you're looking for? Where is this code in the document? Has the document fully loaded when the code is run?


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
  •