Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

URGENT !!!!!!!How to Dynamically add values to dropdownlist using text fields


Level 3

Hi ,

i have a form with two dropdown lists named as Region and State which have a valuse added dynamically to these two dropdowns using java script.

the values in first Drop down R1,R2,R3 and in second dropdown based on the value selected in the first drop down values will populate .

for example: in first dropdown if R1 is selected : in second dropdown R1S1,R1S2,R1S3 values will populate

if  in first dropdown if R2 is selected : In second dropdown R2S1,R2S2,R2S3...etc

And i have check box which will ask user to add more regions to Region dropdown by checking it will display one text filed to enter  region value  and a button which has a java script on click event which will add this text filed value to Region dropdown. And a dialog box will appear if user want to add  new states  for the newly added region .If 'yes' another text filed will appear asking how many states want to add if user enters '1' then one text filed will appear ;if users enters 2 then two text fileds will appear.

Now i need java script which will work in this way : What ever the values i enetr in state textfileds those value need to add to state dropdown with respect to the newly added region..

for example :

Newly entered Region : R4

then if user want to add 2 states for this region the values in text filed could be R4S1,R4S2

And if in region dropdown R4 is selected then in second dropdown(i e State dropdown ) the above values should populate.

Please help me how can i achieve this and let me know if form need to be attached for reference .....

Thanks in advance

G Akhila.

1 Reply


Level 10

Hi reddy,

you can add items to a dropdownlist using the addItem() method

dropDownList1.addItem(txtRegion.rawValue, txtRegion.rawValue);


dropDownList1.addItem(txtRegion.rawValue, dropDownList1.length.toString());

//The first param is the display value

//The second param is the bound value