Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attachEvent 1

Status
Not open for further replies.

lonelydragon

Programmer
Aug 5, 2004
75
0
0
US
hello, i need some help;
i have the following code, but it does not work. i am using attachEvent, but it seems thant i can not put a variable in the "myFunction"? any solution will be highly appecitaed.
btn.attachEvent('onclick',myFunction(myVar));
 
try wrapping it in an anonymous function:
Code:
btn.attachEvent('onclick', function(){ myFunction(myVar) } );

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
hi, jemminger , thank you for your reply, actually, btn.attachEvent('onclick',myFunction(myVar)) is inside of another function like "anotherFunc(myVar){....}:,

you see, "myVar" is passed to it, then can i can pass the "myVar" like your suggestion "btn.attachEvent('onclick', function(){ myFunction(myVar) } )" ?

thank you very much
 
Thanks Jeff, that's a way to solve that problem that I've never seen before. Should come in handy.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top