Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Assign onmouseover event programmatically?Helpful Member! 

FancyPrairie (Programmer) (OP)
22 Sep 06 9:47
I have a field on my html page for which I want to programmatically add an onmouseover event when the user clicks a button.  I thought the following would work, but it doesn't.  What am I doing wrong?

Note the CreateMouseOver sub is called via the onclick event of the button.


Sub CreateMouseOver()

    ctl.onmouseover = "TestMe()"

End Sub

Sub TestMe()

    MsgBox "Here i yam"

End Sub
Helpful Member!  tsuji (TechnicalUser)
22 Sep 06 10:02
> ctl.onmouseover = "TestMe()"
set ctl.onmouseover = getref("TestMe");
tsuji (TechnicalUser)
22 Sep 06 10:03
No semi-colon of course.
    set ctl.onmouseover = getref("TestMe")
FancyPrairie (Programmer) (OP)
22 Sep 06 10:10
Works great, but...

I forgot to mention that I need to pass 2 arguments: a string, and and integer number

What would the syntax look like?
tsuji (TechnicalUser)
22 Sep 06 11:02
Make all the argument to the attributes of the control. The reason is that the event model exposes the srcElement which will be acting as the vehicle. I know you most probably is on some form not in html page, but in html page it is like this.

<script language="vbscript">
sub x(a,b)
    msgbox a & vbcrlf & b
end sub

sub xx    'mimic x
    msgbox a & vbcrlf & b
end sub
sub setup
    set oelem=document.getElementById("btnid")
    oelem.setAttribute "a","arga"
    oelem.setAttribute "b","argb"
    set oelem.onclick=getRef("x")
end sub
set window.onload=getRef("setup")
<button id="btnid">clickme</button>
tsuji (TechnicalUser)
22 Sep 06 11:07
There is a typo or whatever. I meant the corresponding line should be read xx rather than x.
    set oelem.onclick=getRef("xx")
FancyPrairie (Programmer) (OP)
22 Sep 06 15:01
Looks good.  Thanks.  I haven't had a chance to try your new suggestion, but will this evening.  Thanks again for your time.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close