SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    lil help with a menu

    Here is the code:

    Code:
    <script language=javascript>
     menunum=0;menus=new Array();_d=document;function addmenu(){menunum++;menus[menunum]=menu;}function dumpmenus(){mt="<script language=javascript>";for(a=1;a<menus.length;a++){mt+=" menu"+a+"=menus["+a+"];"}mt+="<\/script>";_d.write(mt)};
    </script>
    Now you can see there is an embedded <SCRIPT> tag in the code, which is not good. I pulled this code from a site I am trying to replicate their menu. Can anyone make sense of this, and figure out why there is an embedded <SCRIPT> tag? Thanks!

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    He's using it to write a second script command to the page, which is the actual menu you see.
    It is composed of lines from the array.
    The array must be populated somewhere else, as at present the loop is reading an empty array to create the lines for the second script.
    You have only got part of the menu system here.

    It would have been easier if you'd split the code on a line by line basis at the end of each statement.
    Or even just at the end of each function.


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
  •