![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Internet Explorer Forum Internet Explorer Support. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Aug 2008
Posts: 3
OS: XP Pro 2002 SP 2
|
[SOLVED] Passing (this) in button onClick
******
<script> function func(obj) { alert(obj.id); } </script> <form name="myForm" id="myForm"> <input type="button" id="myButton" name="myButton" value="GO" onClick="func(this);"> </form> ****** When clicking on the GO button, this alert used to display "myButton" - the id of the object being passed. It works this way on Firefox. Today, this alert has started to display "myForm". I am using I.E. 7.0.5730.11 and have been using it for at least a year. What has caused this wierd change in behavior? |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,887
OS: Vista, various linux distros
|
Re: Passing (this) in button onClick
I don't see why this isn't working to be honest. Everything seems fine, have you tried with different attributes?(the value maybe), what are you going to do with it? maybe theres a different way to do what you want.
Cheers, Jamey |
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: Aug 2008
Posts: 3
OS: XP Pro 2002 SP 2
|
Re: Passing (this) in button onClick
Thanks for responding.
It is just an abstract little piece from a larger program that stopped working. The button's onClick has been passing (this) to a function, which among other things, sets the object's disabled property to true. Instead of disabling the button it has started to disable the entire form, b/c it believes it is being passed the form object.... Did you try the little piece on your IE? It probably works OK for you, as it does for other people around me....But in my IE, it thinks it is being passed the form object. Frown. |
|
|
|
|
|
#4 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,887
OS: Vista, various linux distros
|
Re: Passing (this) in button onClick
Yeah, when i use this on IE or using IETab from firefox it works fine. I have no idea why it wouldn't be working.
Actually, have you closed the input tag? (from your example you haven't and that could explain your problem) Code:
<input type="button" id="myButton" name="myButton" value="GO" onClick="func(this);" /> Cheers, Jamey |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Aug 2008
Posts: 3
OS: XP Pro 2002 SP 2
|
Re: Passing (this) in button onClick
Well, this might sound crazy - but yesterday I cleaned out a lot of viruses etc. that were plaguing my laptop, and now the script has once again started to display "myButton" as in days of yore (even without the close input tag). Thanks for bothering.
|
|
|
|
![]() |
| Thread Tools | |
|
|