
Add Option string to select control?
This is from Netscape documentation; I think the "history.go(0)" is not
necessary :> It's also not the best script code I've ever seen either...
but the basic idea is you just change the options array:
cName.options[0] = new Option("Option 1", "opt_1")
<SCRIPT>
function populate(inForm) {
colorArray = new Array("Red", "Blue", "Yellow", "Green")
var option0 = new Option("Red", "color_red")
var option1 = new Option("Blue", "color_blue")
var option2 = new Option("Yellow", "color_yellow")
var option3 = new Option("Green", "color_green")
for (var i=0; i < 4; i++) {
eval("inForm.selectTest.options[i]=option" + i)
if (i==0) {
inForm.selectTest.options[i].selected=true
}
}
history.go(0)
Quote:
}
</SCRIPT>
Quote:
> Hello.
> I use XSL got a string.
> <Option value = 1> Name1</Option>
> <Option value = 2> Name2</Option>
> <Option value = 3> Name3</Option>.
> How can I add them to the select control(cName).
> <select name="cName" >
> </select>
> Thanks.