gszauer
Joined: 11 Jan 2007 Posts: 3
|
Posted: Thu Jan 11, 2007 10:12 pm Post subject: Populating select from array -Help needed |
|
|
| 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){
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: |
| document.mainDcument.playlist.options[i] = new Option(arrayName[i][0]) |
with
| Code: |
| 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 |
|