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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Microsoft Support > Internet Explorer Forum
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Internet Explorer Forum Internet Explorer Support.

Reply
 
LinkBack Thread Tools
Old 08-03-2008, 06:42 AM   #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?
nomivg is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 08-03-2008, 12:43 PM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-04-2008, 04:38 AM   #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.
nomivg is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-04-2008, 04:50 AM   #4 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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);" />
if you have then why don't you post the entirety of your code and i'll see if theres anything going on there.

Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-05-2008, 02:59 AM   #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.
nomivg is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-05-2008, 09:03 AM   #6 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,887
OS: Vista, various linux distros


Re: Passing (this) in button onClick

hmm, that is random haha...

Glad it's sorted,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 09:23 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85