ciao a tutti!
nella pagina asp ho una select che si popola in questo modo:
codice:
<select name="Stato_Op" onchange="setCausale(this)" style="font-family:Verdana; font-size:xx-small; color:#336699;">
<%if ltrim(rtrim(objRs.fields("STATO_OP")))="Aperta" then
response.write "<option value=Aperta selected>Aperta</option>"
else
response.write "<option value=Aperta>Aperta</option>"
end if
if ltrim(rtrim(objRs.fields("STATO_OP")))="Chiusa" then
response.write "<option value=Chiusa selected>Chiusa</option>"
else
response.write "<option value=Chiusa>Chiusa</option>"
end if
if ltrim(rtrim(objRs.fields("STATO_OP")))="Sospesa" then
response.write "<option value=Sospesa selected>Sospesa</option>"
else
response.write "<option value=Sospesa>Sospesa</option>"
end if
if ltrim(rtrim(objRs.fields("STATO_OP")))="Annullata" then
response.write "<option value=Annullata selected>Annullata</option>"
else
response.write "<option value=Annullata>Annullata</option>"
end if%>
</select>
e di conseguenza popola un'altra select con la seguente funzione javascript:
codice:
var regiondb = new Object()
regiondb["Aperta"] = [{value:"102", text:""}];
regiondb["Sospesa"] = [{value:"EDT", text:"EDT"},
{value:"Trouble T", text:"Trouble Ticket"},
{value:"OL in catena", text:"OL in catena"},
{value:"Cliente non reperibile", text:"Cliente non reperibile"}];
regiondb["Annullata"] = [{value:"Servizio gia presente", text:"Servizio gia presente"},
{value:"Annullamento da rete", text:"Annullamento da rete"},
{value:"Cliente rifiuta", text:"Cliente rifiuta"},
{value:"Annullamento causa sistemi", text:"Annullamento causa sistemi"}];
regiondb["Chiusa"] = [{value:"Evasa", text:"Evasa"}];
function setCausale(chooser) {
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["Causale_Op"];
while (cityChooser.options.length) {
cityChooser.remove(0);
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice];
newElem = document.createElement("option");
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);
}
}
}
il problema è che all'apertura della pagina nella seconda select compaiono i campi corrispondenti al primo valore della prima select,qualsiasi sia il valore di quest'ultima.come posso risolvere il problema?