Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have two dropdowns with same content, by selection of one dropdown I want to reflect same in other dropdown.

In dropdown again I have checkbox selection.

For textbox I did like

JavaScript
text_id_1 = document.getElementById("text_id_1");
    text_id_2 = document.getElementById("text_id_2");
    text_id_2.value = text_id_1.value;


How to do for dropdown list.

Plz suggest me.
Posted

In SelectedIndexChanged event of dropdown1, set the SelectedIndex of dropdown2 to SelectedIndex of dropdown1.

C#
void dropdown1_SelectedIndexChanged(object sender, EventArgs e)
        {            
            dropdown2.SelectedIndex = dropdown1.SelectedIndex;
        }
 
Share this answer
 
Try:
JavaScript
function SelectCorrespondinValue()
{
var dropdownlisttwo = document.getElementById("DropDownListTwo");
var e = document.getElementById("dropdownlistone");
var selectedValue = e.options[e.selectedIndex].text;

for(var i = 0; i < dropdownlisttwo.length -1; i++)
{
    if(selectedValue == dropdownlisttwo.options[i].text)
    { 
        dropdownlisttwo.selectedIndex = i;
    }
}
}


Call this function on "change" event of your first DropdownList. Let me know if it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900