DarkSun84
21-01-2008, 08:47
Ciao, volevo sapere perchè non funziona l'attributo onchange sulla select che viene creata tramite DOM, ossia quando apro la pagina mi apre subito l'alert mentre me lo dovrebbe aprire nel momento in cui cambio un'opzione nella select.
var address= document.createElement('select');
address.setAttribute("id",'addressHttp');
address.setAttribute("name",'addressHttp'+numberRow);
address.onchange= alert("change!");
theOption= document.createElement("OPTION");
theText= document.createTextNode("www.esa.it");
theOption.setAttribute("value","http://www.esa.int/esaCP/Italy.html");
theOption.appendChild(theText);
address.appendChild(theOption);
//altre opzioni...
document.getElementById("formID").appendChild(address);
var address= document.createElement('select');
address.setAttribute("id",'addressHttp');
address.setAttribute("name",'addressHttp'+numberRow);
address.onchange= alert("change!");
theOption= document.createElement("OPTION");
theText= document.createTextNode("www.esa.it");
theOption.setAttribute("value","http://www.esa.int/esaCP/Italy.html");
theOption.appendChild(theText);
address.appendChild(theOption);
//altre opzioni...
document.getElementById("formID").appendChild(address);