How to change Dropdown lists value based on another Dropdown using javascript?

murad779

New Member
I have three Dropdowns.(Adult,Child and Infant- like Airline Booking Site). In general, Adult DDL (1-9), Child DDL(0-8), Infant DDL(0-1). If a user select Adult value as '4' the Child DDL value should change as(0-5) and Infant DDL value should change as(0-4). How to achieve this using javascript ? I tried but could not achieve. Please inform to me if you need more information from my side.\[code\] function MyApp(sender) { var ListBox1Id = '<%= ddl1.ClientID %>'; var ListBox2Id = '<%= ddl2.ClientID %>'; var ListBox3Id = '<%= ddl3.ClientID %>'; var selectedIndex = document.getElementById(ListBox1Id).selectedIndex; var ii = document.getElementById(ListBox1Id).options[selectedIndex].value; var count = document.getElementById(ListBox1Id).length; if (ii != 0) { for (var k = 0; k <= count - ii; k++) { document.getElementById(ListBox2Id).value = http://stackoverflow.com/questions/14068911/k;\[/code\]}}This function calls from Adult DDL(On change)And I have written script for showing Child DDL value from Adult DDL selection.
 
Back
Top