Having problems with setTimeout with a parameter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tgmurray
    New Member
    • Aug 2007
    • 5

    Having problems with setTimeout with a parameter

    I am trying to use setTimeout with a function that has a parameter and I keep getting the error message theitem has no properties.

    I am presently working on windows xp pro with Firefox as my browser.

    [CODE=javascript]
    previous = "";
    previousmenuite m = "";

    function removeitem (theitem) {
    alert(theitem);
    theitem.style.d isplay= "none";
    }

    function displaymenu(mea ltype)
    {
    if (mealtype)
    {
    if (previous != "")
    for (i=document.get ElementById(pre vious).getEleme ntsByTagName('d iv').length-1; i >= 0;i--)
    //setTimeout("tim eout3("+param+" )", 5000);
    //setTimeout(func tion(){theFunct ion(p1,p2,p3);} , ms);
    setTimeout(func tion() {removeitem(doc ument.getElemen tById(previous) .getElementsByT agName('div')[i]);}, 1000);


    number = document.getEle mentById(mealty pe).getElements ByTagName('div' ).length;

    for (i=0; i < number;i++)
    document.getEle mentById(mealty pe).getElements ByTagName('div' )[i].style.display= "block";
    previous=mealty pe;
    }
    }
    [/CODE]

    Again, the error code is theitem has no properties

    Thanks in advance,
    Terry
    Last edited by acoder; Sep 19 '07, 04:33 PM. Reason: Added language to code tag
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Show the HTML markup that goes with this Javascript code.

    Comment

    • tgmurray
      New Member
      • Aug 2007
      • 5

      #3
      I was asked to show the HTML in addition to the Javascipt so here it is:
      recall the error message that I am receiving is: theitem has no properties

      [CODE=html]
      <div id="Breakfast" >
      <a href="" onclick="displa ymenu('Breakfas t');this.href=' javascript:void (0)'">Breakfast </a></br>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b1')">Ra ncheros</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b2')">Br eakfast Burrito </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b3')">Su nrise Quesadilla </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b4')">Or ganic Mechanic </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b5')">Au ssie Platter </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b6')">Nu mber Three </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b7')">Fr ench Toast </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b8')">Gr anola</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('b9')">No la Granola </a>
      </div>

      </div>
      <div id="Lunch">
      <a href="" onclick="displa ymenu('Lunch'); this.href='java script:void(0)' ">Lunch</a></br>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l1')">Gr een Mango Salad </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l2')">Qu esadilla </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l3')">Po p 300 Million Wrap </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l4')">Hu evos con Chorizo</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l5')">Ch ilaquiles</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l6')">Re d Chilaquiles </a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('l6')">Na chos</a>
      </div>





      </div>
      <div id="Dinner">
      <a href="" onclick="displa ymenu('Dinner') ;this.href='jav ascript:void(0) '">Dinner</a></br>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('d1')">Di nner 1</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('d2')">Di nner 2</a>
      </div>
      <div class="menuitem ">
      <a href="" onclick="showCo ntent('d3')">Di nner 3</a>
      </div>
      </div>
      [/CODE]
      Last edited by acoder; Sep 20 '07, 12:06 PM. Reason: Added language to code tag

      Comment

      Working...