Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

onchange not working

Anybody know why the onchange() isn't working?  This is the error I get
Uncaught ReferenceError: getProj is not defined
    at HTMLSelectElement.onchange


http://jsfiddle.net/isogunro/r6e4gm34/

<select id="contracts" onchange="getProj(this)">
  <option value=""></option>
</select>
<span id="ctType"></span>


function getProj(sel) {
var ct = document.getElementById("ctType");
ct.innerHTML = contractAry[2].contractType;
	alert(sel.value);
  
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
issue is you selected run the code on window.onload, which messes everything...
if you put that one in <script>...<script> tags, it will work

your code is wrapped with

window.onload=function(){
...
}

Open in new window


jsFiddle adds this if you select onLoad
Avatar of Isaac

ASKER

How did you get it to work in your fiddle though?  It's exactly like mines but yours works and mines doesn't.
:) magic

User generated image