SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    IRL
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Object expected error.... ???

    Okay the following code always throws up the Object expected error line 13, character 14 which is at the i < sizeof(... line

    function showmenu(x)
    {
    document.write("<table border='1' width='100'><tr><td><select id='a' style='visibility: visible;'>");
    for(var i=0;i < sizeof(x); i++) document.write("<option>"+x[i]+"</option>");
    document.write("</select></td></tr></table>");
    }

    I can't for the life of me figure out why this is happening... anyone have any suggestions?

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does x definitely have a value? ie: you're executing showmenu('menuitem') or something. I'm no JS expert, but that would be my first thing to look at.

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where's sizeof()? What does it do? Is x really an array?

    BTW, it's generally considered a Bad Idea™ to call a function at every iteration of a for loop. Just bad coding practice, since it will (presumably) return the same value each time.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •