Add Option string to select control? 
Author Message
 Add Option string to select control?

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.



Sat, 10 May 2003 03:00:00 GMT  
 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.



Sat, 10 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. changing select options based on previously selected options

2. add option to select list

3. Netscape 6 - adding an option to select

4. Adding options to a select element

5. Prob when adding new OPTION to SELECT

6. add new option item to the select from another frame

7. Add option method to form.select object

8. Add fields to a form by selecting the option to do so

9. how to add OPTION element in SELECT at runtime using Client side vbscripting

10. Prob when adding new OPTION to SELECT

11. Dynamically adding OPTION to SELECT

12. Adding OPTION Element to SELECT

 

 
Powered by phpBB® Forum Software