Salve a tutti!!
stavo cercando di modificare questo script in modo che potesi mettere più select dinamiche che dipendono una dall'altra:
solo che quando clicco sulla seconda selecr improvisamente scompare il contenuto!codice:<html><head> <title>Esempio - Select dinamiche</title> <script type="text/javascript"> var regiondb = new Object() regiondb["locazioni"] = [ {value:"1", text:"Locazione 1"}, {value:"2", text:"Locazione 2"}, {value:"3", text:"Locazione 3"}, {value:"4", text:"Locazione 4"}, {value:"5", text:"Locazione 5"}, {value:"7", text:"Locazione 7"}, {value:"8", text:"Locazione 8"}, {value:"56", text:"ciao"}]; regiondb["utenti"] = [ {value:"1", text:"Lugaid"}, {value:"2", text:"Vandroiiy"}]; function setCities(chooser, formSelect) { var newElem; var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null; var cityChooser = chooser.form.elements[formSelect]; //var cityChooser = chooser.form.elements[formSelect]; while (cityChooser.options.length) { cityChooser.remove(0); } var choice = chooser.options[chooser.selectedIndex].value; var db = regiondb[choice]; newElem = document.createElement("option"); newElem.text = "Seleziona:"; newElem.value = ""; cityChooser.add(newElem, where); if (choice != "") { for (var i = 0; i < db.length; i++) { newElem = document.createElement("option"); newElem.text = db[i].text; newElem.value = db[i].value; cityChooser.add(newElem, where); } } } </script></head> <body> <form name="form"> <select name="lopl[]" onchange="setCities(this, '1')"> <option value="" selected="selected">Seleziona:</option> <option value="locazioni">Locazioni</option> <option value="utenti">Utenti</option> </select> <select name="lol[]" > <option value="" selected="selected">Seleziona:</option> </select> <select name="lopl[]" onchange="setCities(this, '2')"> <option value="" selected="selected">Seleziona:</option> <option value="locazioni">Locazioni</option> <option value="utenti">Utenti</option> </select> <select name="lol[]" > <option value="" selected="selected">Seleziona:</option> </select></form> </body></html>
qualcuno mi da una mano? grazie

Rispondi quotando
