Results 1 to 3 of 3

Thread: Need some help on a loop

  1. #1
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need some help on a loop

    Code:
      <script language="Javascript" type="text/javascript">
      <!-- Hide from older browsers
      a0 = new array(
        new Array("title", "url"),
        new Array("title2", "url"),
        new Array("title3", "url")
      )
      function changeMenu (arrayName){
       selected =  document.mainDcument.categories.options[document.mainDcument.categories.selectedIndex].value
        if (selected != ""){
            selectedValue = parseInt(selected)
            document.mainDcument.playlist.options.length = 0
            for (i=0; i<=arrayName.length ; i++){
                document.mainDcument.playlist.options[i] = new Option(arrayName[i][0])
                 // arrayName[i][0]
                //document.mainDcument.playlist.options[i].value = i
            }
        }
      }
      // end hiding script -->
        </script>
    If i replace
    Code:
     document.mainDcument.playlist.options[i] = new Option(arrayName[i][0])
    with
    Code:
     document.mainDcument.playlist.options[i] = new Option("Dummy")
    The script works just fine, but otherwise it refuses to populate my other list...
    Can anyone please help out?
    I appriciate your time
    Thanks
    ~Gabor

  2. #2
    Join Date
    Dec 2006
    Posts
    47
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default

    I would look into this...

    a0 = new array();
    a0[0]= new Array("title", "url");
    a0[1]= new Array("title2", "url");
    a0[2]= new Array("title3", "url");

  3. #3
    Join Date
    Jan 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    tryed that it didn't work.
    Also, to my knowlege in Javascript you do not need to end your lines with ;


    If it helps, my full code is
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title></title>
      <script language="Javascript" type="text/javascript">
      <!-- Hide from older browsers
      a0 = new array(
        new Array("title", "url"),
        new Array("title2", "url"),
        new Array("title3", "url")
      )
      function changeMenu (arrayName){
       selected =  document.mainDcument.categories.options[document.mainDcument.categories.selectedIndex].value
        if (selected != ""){
            selectedValue = parseInt(selected)
            document.mainDcument.playlist.options.length = 0
            for (i=0; i<=arrayName.length ; i++){
                document.mainDcument.playlist.options[i] = new Option(arrayName[i][0])
                 // arrayName[i][0]
                //document.mainDcument.playlist.options[i].value = i
            }
        }
      }
      // end hiding script -->
        </script>
    </head>
    <body>
    <form name="mainDcument" action="http://">
        <select name="categories" size="5" id="categories" onchange="changeMenu ('a0')">
             <option value="0">populate</option>
            <option value="1">populate</option>
            <option value="2">populate</option>
        </select>
        <select name="playlist" size="5" id="playlist" onChange="changeMenu ()">
             <option value="0">UnPopulated</option>
        </select>
    </form>
    </body>
    </html>
    Last edited by gszauer; 01-11-2007 at 01:46 AM.

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
  •