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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -