Hello, I have got a problem and since I am still a newbie @ js, could you guys please help me out?
This is the script:
in the body:
I keep getting the error that array is undefined. It refers to the array i used in the a tag.
This is the script:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| </style>
<script type=Javascript>
new array = new Array(
new Array(
new Array("test");
new Array("test2");
);
);
for(i=0;i<=array.length;i++){ document.write(array[i]);}
function getselect(posts,cats){
var i;
for(i=0;i=posts.options.length;i++){
posts.options[i] = NULL;
}
for(i=0;i=cats.length;i++){
posts.options[i]=new Option(cats[i]);
posts.options[i].value=cats[i];
}
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
</script> |
in the body:
code:
1
2
3
4
5
6
7
8
9
10
11
| <select name=cats onchange="getselect(this.form.posts,array[this.selectedindex]);"> <option value=1>Choose a category<option value=2>home</option><option value=3>anime</option> </select> <br> <br> <b>Posts:</b> <br> <select name=posts> <option></option> <option></option> </select> |
I keep getting the error that array is undefined. It refers to the array i used in the a tag.