Link to home
Start Free TrialLog in
Avatar of wrynn
wrynn

asked on

how do i assign an onchange function to a select field within my javascript code?

i want to dynamically assign an onchange function to a select field in my javascript code.

so lets say i have this code:

function eventHandler(param1) {

           doSomeStuff(param1);
}

selectField.onchange=eventHandler("blah");



obviously this is the wrong way, what is the correct way?

selectField.onchange = function() { eventHandler("blah"); }


is this the correct way?





ASKER CERTIFIED SOLUTION
Avatar of Basilisci
Basilisci

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