vj5 Posted May 29, 2008 Share Posted May 29, 2008 I have multiple dropdown list on a page and I want to click the first dropdown and the second dropdown should move down and give way to the first dropdown, when click on second dropdown, the third dropdown should move down and give way tot he second. Is it possible to do like I explained? Link to comment Share on other sites More sharing options...
aspnetguy Posted May 29, 2008 Share Posted May 29, 2008 do you want the drop downs to pyhsically move or do you mean you want to load the lower drop downs based on the selection of the drop down above it (i.e populate a state dro down after a country has been selected from the previous drop down)? Link to comment Share on other sites More sharing options...
vj5 Posted May 29, 2008 Author Share Posted May 29, 2008 do you want the drop downs to pyhsically move or do you mean you want to load the lower drop downs based on the selection of the drop down above it (i.e populate a state dro down after a country has been selected from the previous drop down)?Physically move when the first dropdown is selected.When second dropdown is selected, the third should move and the first should close the selection. Link to comment Share on other sites More sharing options...
aspnetguy Posted May 29, 2008 Share Posted May 29, 2008 you will need to attach an onchange event handler in javascript to the dropdownlist like so <asp:DropDownList ID="DropDownList1" runat="server" onchange="ddl1change()"/><br/><asp:DropDownList ID="DropDownList2" runat="server" onchange=""/>...<script type="text/javascript"> function ddl1change() { //write your javascript code to move ddl2 }</script> Link to comment Share on other sites More sharing options...
vj5 Posted May 29, 2008 Author Share Posted May 29, 2008 something like the one in the link below:http://www.ajaxtopics.com/menu.html Link to comment Share on other sites More sharing options...
vj5 Posted May 29, 2008 Author Share Posted May 29, 2008 you will need to attach an onchange event handler in javascript to the dropdownlist like so<asp:DropDownList ID="DropDownList1" runat="server" onchange="ddl1change()"/><br/><asp:DropDownList ID="DropDownList2" runat="server" onchange=""/>...<script type="text/javascript"> function ddl1change() { //write your javascript code to move ddl2 }</script> Could you give an example of javascript code to write for dd12? where is the second dropdownlist onchange=""? Link to comment Share on other sites More sharing options...
vj5 Posted May 29, 2008 Author Share Posted May 29, 2008 you will need to attach an onchange event handler in javascript to the dropdownlist like so<asp:DropDownList ID="DropDownList1" runat="server" onchange="ddl1change()"/><br/><asp:DropDownList ID="DropDownList2" runat="server" onchange=""/>...<script type="text/javascript"> function ddl1change() { //write your javascript code to move ddl2 }</script> I am gettting an error saying onchange is not valid asp.net control. Link to comment Share on other sites More sharing options...
aspnetguy Posted May 29, 2008 Share Posted May 29, 2008 I don't fully understand what you mean when you want the drop downs to move when an option is selected fromt he previos one.Try assigning the handlers this way. <asp:DropDownList ID="DropDownList1" runat="server"/><br/><asp:DropDownList ID="DropDownList2" runat="server"/><br/><asp:DropDownList ID="DropDownList3" runat="server"/>...<script type="text/javascript"> //assign handlers document.getElementById('<%= DropDownList1.ClientID %>').onchange = function() { //you can use this.style to access the drop downs css properties to make it move // use position, top, and left to move the dopr down }; document.getElementById('<%= DropDownList2.ClientID %>').onchange = function() { }; document.getElementById('<%= DropDownList3.ClientID %>').onchange = function() { }; </script> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.