dcsimg
How to change the dropdown values dynamically
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kums_sk
Posted On:   Friday, June 21, 2002 03:11 AM

Hi..

I want to load the "select" dropdown values dynamically.
That is i am getting the values of dropdown from the data base.
how to set the set it dynamically.Any one please help me in this.


Thanks in advance,


Regards,

kumarappan.s

Re: How to change the dropdown values dynamically

Posted By:   Firat_Tiryaki  
Posted On:   Saturday, June 22, 2002 04:29 AM

You should use Option object to dynamically edit the combo boxes.



The Option object is created using the word new


myOption= new Option();



the text and the value of the Option object is set just like below


myOption.text="option text here";

myOption.value="option value here";


The option can be inserted into selection defining the option index number. Below the option is inserted at the end of a selection



document.formName.selectName.options[document.formName.selectName.options.length]=myOption;



The option can be deleted just setting the option to null


document.formName.selectName.options[1]=null; --> the second option is deleted.



Take a look at the brief example below to make sure about how the things are going.


--------------------------------------------------





Untitled








Enter the text of the new option here:


Enter the value of the new option here:






This button deletes the selected option or the last option



This button deletes all of the options









--------------------------------------------------

About | Sitemap | Contact