#SEO and Investing Expert-II
New Member
When u've got 2 DropDownLists how do you change the values displayed in one of the lists depending on the selected value of the other list. e.g. list 1 has all the programs and list 2 all the modules and only those modules may show that are part of the selected program...preferrably without posting the page back<BR><BR>thanxYou will need to use javascript. Build some arrays with the values you want for each selected value. You can find scripts around for this.you can call a function in first dropdownlist 'onchange' event which generates the values and text of second dropdownlist.<BR><BR>regards<BR>rajkumarsomething like this:<BR><BR>http://javascript.internet.com/forms/dropdown-box-population.htmlthanx, but i get my values from two database tables, so i'll guess i'll have to find a way to make this work through xml...Hi,<BR><BR>I'm interested in the same problem - do you have any ideas about how you would do this via XML?<BR><BR>JONnope, i just spend the afternoon and evening looking for a solution, but in vain. Keep you posted though when i should find it.Any solution that does not involve a post back will have to be javascript all of the client-side. You can response.write out the javascript with the values, I have done this before and it works fine. I create a string and then assign it to a literal rather than response.write, but either way would work.i had to go for the server side thing...<BR><BR>private void DdlSystems_SelectedIndexChanged(object sender, System.EventArgs e)<BR>{<BR> int choice = DdlSystems.SelectedIndex ;<BR> FillDdlReleases(choice+1);<BR>}<BR><BR>private void FillDdlReleases(int aChoice)<BR>{<BR>Releases = new BugTracker.ReleasesDB(); <BR>DdlReleases.DataSource = Releases.GetReleases(aChoice);<BR>DdlReleases.DataTextField = "Release Version";<BR>DdlReleases.DataValueField = "Release ID";<BR>DdlReleases.DataBind();<BR>}Another option is to use a Web Service that is called from client side code to retrieve the data you want and refresh the dropdown list with the updated values. The main advantage to this, is that the only thing that is retrieved from the server is the data you need, not the entire contents of the page as is normally the case with server postbacks. It is a great performance enhancement! Here is the link:<BR><BR>http://www.fawcette.com/vsm/2002_06/online/delcogliano/If you want to use XML you can load an XML document into the page and then use javascript and the DOM model to access the nodes dynamically based on the selection of the first drop down. the javascript could load the page by calling another asp page that will retrieve the xml and never appear to be using another request. I have some examples if this is of any interest to you. Hope this helps.I'd be interested in some examples!<BR><BR>JONThis is basically just how you would call the LoadEmpName onChange and pass in the value from that drop down and then make a call to an asp page that must return a XML doc to be loaded into the DOM parser. Then you can access the nodes after the XML has been loaded (ready state 4). Now you can loop through the nodes in the XML to repopulate another drop down using javascript. I didn't leave the details in regarding that piece as you'd likely have your own object names to put there anyway. Let me know if you have any questions but this model will basically allow you to build in what appears to be client side functionality while actually making calls to the server to return whatever you want. The xml.asp page could bring back an xml doc from a stored procedure with whatever you want. <BR><BR>function loadEmpName(){<BR> xmlEmpName = new ActiveXObject('microsoft.XMLDOM');<BR> xmlEmpName.onreadystatechange = loadName;<BR> xmlEmpName.validateOnParse = true;<BR> xmlEmpName.async = true;<BR> xmlEmpName.load('xml.asp');<BR>}<BR><BR>function loadName(){<BR> if(xmlEmpName.readyState == 4){<BR> if(xmlEmpName.parseError.errorCode != 0) <BR> showError(xmlEmpName)<BR> else<BR> loadNameDetail(); <BR> }<BR>}<BR><BR>function loadNameDetail(){<BR> oName = xmlEmpName.getElementsByTagName("[XMLTAGNAME]").item(0);<BR> [HTMLELEMENT].innerText = oName.getElementsByTagName("[XMLTAGNAME]").item(0).text;<BR> [HTMLELEMENT].value = http://aspmessageboard.com/archive/index.php/oName.getElementsByTagName("[XMLTAGNAME]").item(0).text;<BR>}Thanks for the code, I'll have a play around with it!I actually have a server side VBScript function the spits out the html and javascript to do this. Feed it the recordset, naming, and the parent list and it spits out the rest. email me if your interested in a copy.Am interested!