More JS Issues

Codegen

Gawd
Joined
Aug 28, 2004
Messages
915
Ok, so I'm trying to follow this guide: http://www.sislands.com/coin70/week5/onChange.htm

The problem I'm having is that it only populates the listbox with the first letter of the array name. If I alert the variable used to do an eval(Monitor), it will alert me with Monitor, and the lsitbox will be populated with 'M'.

This is the code that I've written:

Code:
[SIZE=3]function tablelist(PC) {[/SIZE]
[SIZE=3]var Select1 = document.add.type;[/SIZE]
[SIZE=3]    var _Array = eval(PC);[/SIZE]
[SIZE=3]    setOptionText(Select1, _Array);[/SIZE]
[SIZE=3]    alert(_Array);[/SIZE]
[SIZE=3]}[/SIZE]

[SIZE=3]function setOptionText(Select1, _Array)[/SIZE]
[SIZE=3]{    [/SIZE]
[SIZE=3]    for (loop = 0; loop < Select1.options.length; loop++) {[/SIZE]
[SIZE=3]        Select1.options[loop].text = _Array[loop];[/SIZE]
[SIZE=3]    }[/SIZE]
[SIZE=3]}[/SIZE]

Edit: Oh, and before all that:

Code:
var PC = new Array("Desktop", "Laptop")
 
Do you mean the values? I only have one entry being "-------" because everything is disabled when you first load it. - oh crap, are you supposed to still have the options in the select box?
 
Back
Top