Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
1.00/5 (2 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
Comments
Eduard Keilholz 10-Oct-13 10:17am    
Copy of http://www.codeproject.com/Questions/666498/For-the-dropdown-selection-reflect-the-same-to-oth
thatraja 10-Oct-13 10:21am    
checkbox? where's it?

1 solution

Use the selectedIndex
ASP
<!DOCTYPE html>
<html>
<head>
<script language="JavaScript">
<!--
function selectChange1() {
   document.getElementById("dropdown2").selectedIndex =
   document.getElementById("dropdown1").selectedIndex;
}
function selectChange2() {
   document.getElementById("dropdown1").selectedIndex =
   document.getElementById("dropdown2").selectedIndex;
}
//-->
</script>
</head>
<body>

<select name="dropdown1" onChange="selectChange1()">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

<select name="dropdown2" onChange="selectChange2()">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

</body>
</html>
 
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