bairdb Posted December 27, 2005 Share Posted December 27, 2005 <html> <head> <script language="javascript"> function setOptions(o) { var select2 = document.form1.select2; select2.options.length = 0; if (o == "1") { select2.options[select2.options.length] = new Option('Apple'); select2.options[select2.options.length] = new Option('Pear'); } if (o == "2") { select2.options[select2.options.length] = new Option('Carrot'); select2.options[select2.options.length] = new Option('Potatoe'); } if (o == "3") { select2.options[select2.options.length] = new Option('Chicken'); select2.options[select2.options.length] = new Option('Fish'); }if (o == "4") { select2.options[select2.options.length] = new Option('Cheddar'); select2.options[select2.options.length] = new Option('Swiss'); } } </script> </head> <body> <form name="form1"> <select name="select1" size="1" onchange="setOptions(document.form1.select1.options[document.form1.select1.selectedIndex].value);"> <option value="1">Fruit</option> <option value="2">Vegetable</option> <option value="3">Meat</option> </select> <br /> <br /> <select name="select2" size="1"> <option>Apple</option> <option>Pear</option> </select> </form> </body> </html></body> </html> I have this code with some javascript that will change the value of the second drop down box depending on what is selected in the first drop down. Can anyone help me with some asp code to make these options populate dynamically from a database? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now