Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > OnClick event

Reply
Thread Tools

OnClick event

 
 
f1crazed@gmail.com
Guest
Posts: n/a
 
      02-01-2005
Hello,

I am wanting to fire the onClick event of button1 by pressing button2.
Does anyone have a clue if this is even posible? If so PLEASE HELP!!
Thanks.

 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      02-01-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) said:
>
>Hello,
>
>I am wanting to fire the onClick event of button1 by pressing button2.
>Does anyone have a clue if this is even posible? If so PLEASE HELP!!
>Thanks.
>


<button onclick="doSomething()">button1</button>
<button onclick="doSomething()">button2</button>

How is what you want different from this?

 
Reply With Quote
 
 
 
 
Dietmar Meier
Guest
Posts: n/a
 
      02-01-2005
(E-Mail Removed) wrote:

> I am wanting to fire the onClick event of button1 by pressing
> button2. Does anyone have a clue if this is even posible?


Here is a test document. Watch the differing behaviour of MSIE
compared to other Browsers (Mozilla, Opera, Netscape 4) when
clicking the second button:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN Transitional"
"http://www.w3.org/TR/html4/transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Some Events</title>
<script type="text/javascript">
window.name = "myWindow";
</script>
</head>
<body>
<form action="" name="myForm"><p>
<input type="button" value="1" name="myButton1"
onclick="alert(this.name + '\n' + (event &amp;&amp; event.type))"
>

<input type="button" value="2" name="myButton2"
onclick="var o = form.elements['myButton1'], h = o.onclick;
if (typeof h == 'function') h()"
>

<input type="button" value="3" name="myButton3"
onclick="var o = form.elements['myButton1'], h = o.onclick;
if (h && h.apply) h.apply(o, [event])"
>

<input type="button" value="4" name="myButton4"
onclick="var o = form.elements['myButton1'], h = o.onclick;
if (h && h.apply) h.apply(this, [event])"
>

</p></form>
</body>
</html>

ciao, dhgm
 
Reply With Quote
 
f1crazed@gmail.com
Guest
Posts: n/a
 
      02-02-2005
Dietmar,
Thankyou!!!! This is what I was wanting to do. Thanks so much!!!!

JD

 
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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overriding an onclick with another onclick tomlong@gmail.com Javascript 4 01-26-2006 09:26 PM
how to handle both onmouseup event and onClick event JerryG ASP .Net 0 12-20-2005 03:49 AM
button.onclick = new Function("func2()") + button.onclick foldface@yahoo.co.uk Javascript 2 09-26-2005 08:13 AM
Problem onClick event on Firefox orion30 Firefox 0 11-07-2004 02:34 PM
document.onclick=doIt() same as document.onclick=doIt ? bob Javascript 3 08-21-2003 12:14 PM



Advertisments