It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Populating select from array -Help needed

Populating select from array -Help needed

Postby gszauer on Thu Jan 11, 2007 9:12 pm

Code: Select all
<!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){
        document.mainDcument.playlist.options.length = 0
        for (i=0; i<=arrayName.length ; i++){
            document.mainDcument.playlist.options[i] = new Option(arrayName[i][0])
         
      }
  }
  // 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>

As you can see i am using one list to populate a nother list.
However the code does not work. But if i replace
Code: Select all
document.mainDcument.playlist.options[i] = new Option(arrayName[i][0])

with
Code: Select all
document.mainDcument.playlist.options[i] = new Option("EDGE")

It works just fine....
I have no clue why this messes up so bad....
Can anyone please help out?
I really appriciate your time
Thank you,
~Gabor Szauer
gszauer
 
Posts: 3
Joined: Thu Jan 11, 2007 8:55 pm

Who is online

Users browsing this forum: No registered users and 4 guests