I need help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eLLa enchanted
    New Member
    • Dec 2006
    • 2

    I need help

    Im new to Javascript, and im doing a page and im creating a page that has a tab menus.. which each tab are images.

    i dont know what to do with the error, it goes something like this:
    document.getEle mentById(id) has no properties

    heres my code:


    function setActiveTab(id )
    {
    var a = new Array;
    a = ("img1", "img2", "img3");

    document.getEle mentById(id).sr c = "../images/tab_nowshowing_ gray.jpg";

    for(var i = 0; i < a.length; i++)
    {
    if(a[i] != id){
    document.getEle mentById(a[i]).src= "../images/tab_comingsoon_ gray.jpg";
    document.getEle mentById(a[i]).src= "../images/tab_nextattract ion_gray.jpg";
    }
    }
    }

    ---------------------

    hope somebody could help me
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    Originally posted by eLLa enchanted
    Im new to Javascript, and im doing a page and im creating a page that has a tab menus.. which each tab are images.

    i dont know what to do with the error, it goes something like this:
    document.getEle mentById(id) has no properties

    heres my code:


    function setActiveTab(id )
    {
    var a = new Array;
    a = ("img1", "img2", "img3");

    document.getEle mentById(id).sr c = "../images/tab_nowshowing_ gray.jpg";

    for(var i = 0; i < a.length; i++)
    {
    if(a[i] != id){
    document.getEle mentById(a[i]).src= "../images/tab_comingsoon_ gray.jpg";
    document.getEle mentById(a[i]).src= "../images/tab_nextattract ion_gray.jpg";
    }
    }
    }

    ---------------------

    hope somebody could help me
    I didn't test your code, but a few things. You specify that you want an Array then in your getelementbyid statement you only asign 2 an image location. Also, you have one to many closing brace ( } ). Also, you need to use getelementbyid like so .getElementById ("myElementByID ")

    HTH,
    Aric

    Comment

    Working...