javascript function won't run onchange -
window.onload = init; function init(){ var allselect = document.getelementsbytagname("option"); (var = 0; < allselect.length; i++){ allselect[i].onchange = loadlink; } } function loadlink(){ alert("test"); }
so i'm working on problem class , functions incredibly simple. replaced code needed simple alert because tracking break point point doesn't run loadlink() function. allselect populated , have onchange value specified code in {}.
i have tried putting html element hand , still doesn't work.
any ideas? i'm running locally on computer both ie , chrome if cares know. ahead of time.
the onchange event belongs on select element, not option elements. so:
window.onload = init; function init(){ var allselect = document.getelementsbytagname("select"); (var = 0; < allselect.length; i++){ allselect[i].onchange = loadlink; } } function loadlink(){ alert("test"); }
Comments
Post a Comment