473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Multiple handlers for a given function

Is there a shorthand way to assign the same actions to multiple handlers
? I know I can just just do:
onBlur='myFunction()';onClick='myFunction()'

I'm just looking to save some keystrokes. I actually have this issue now
and it involves a couple of functions with long parameter lists.
TIA
Sep 8 '06 #1
3 1237
Lorenzo Thurman said the following on 9/8/2006 2:00 PM:
Is there a shorthand way to assign the same actions to multiple handlers
? I know I can just just do:
onBlur='myFunction()';onClick='myFunction()'

I'm just looking to save some keystrokes. I actually have this issue now
and it involves a couple of functions with long parameter lists.
<element id="someID" onclick="something('longParameterList')">

window.onload=duplicateThem()

function duplicateThem(){
document.getElementById('someID').onblur=document. getElementById('someID').onmouseover
}

How do you blur something without clicking it though?
The only way to do that is by setting focus via script and if you are
doing that, you simply call the same function.

Or you can write a wrapper function:

function dummyFunction(objectCallingMe){
someOtherFunction('All my parameters here',objectCallingMe)
}

objectCallingMe is in case you are passing "this" as a parameter.

onclick="dummyFunction()" onblur="dummyFunction()"

Of all the possibilities, I would combine the two, it allows less room
for typo errors.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 8 '06 #2
Randy Webb said the following on 9/8/2006 3:13 PM:
Lorenzo Thurman said the following on 9/8/2006 2:00 PM:
>Is there a shorthand way to assign the same actions to multiple
handlers ? I know I can just just do:
onBlur='myFunction()';onClick='myFunction()'

I'm just looking to save some keystrokes. I actually have this issue
now and it involves a couple of functions with long parameter lists.

<element id="someID" onclick="something('longParameterList')">

window.onload=duplicateThem()
That should be:

window.onload=duplicateThem;

without the ()

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Sep 8 '06 #3
Randy Webb wrote:
Lorenzo Thurman said the following on 9/8/2006 2:00 PM:
>Is there a shorthand way to assign the same actions to multiple
handlers ? I know I can just just do:
onBlur='myFunction()';onClick='myFunction()'

I'm just looking to save some keystrokes. I actually have this issue
now and it involves a couple of functions with long parameter lists.

<element id="someID" onclick="something('longParameterList')">

window.onload=duplicateThem()

function duplicateThem(){
document.getElementById('someID').onblur=document. getElementById('someID').onmouseover

}

How do you blur something without clicking it though?
The only way to do that is by setting focus via script and if you are
doing that, you simply call the same function.

Or you can write a wrapper function:

function dummyFunction(objectCallingMe){
someOtherFunction('All my parameters here',objectCallingMe)
}

objectCallingMe is in case you are passing "this" as a parameter.

onclick="dummyFunction()" onblur="dummyFunction()"

Of all the possibilities, I would combine the two, it allows less room
for typo errors.
Thanks, I'll go with combining them.
Sep 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
3
by: Jeff Shannon | last post by:
I'm having some difficulty getting my logging configuration set correctly. I'm using a config file (copied at end of post), with the intent of setting several loggers which write to a combination...
9
by: chandramohan.mani | last post by:
Does Event handlers work in netscape. If yes means can anyone please help me. <HTML><SCRIPT LANGUAGE="JScript"> function mouseclick() { alert("I was clicked on " +...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
15
by: Iced Crow | last post by:
In C# I know that you can use delegates to assing multiple addresses of sub and functions to a delegate and have it fire multiple procedures... How do I do this in VB? I only know of assigning...
13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
6
by: Peter M. | last post by:
Hi all, If an event has multiple subscribers, is it possible to cancel the invocation of event handlers from an event handler? Or to be more specific: I'm subscribing to the ColumnChanging...
1
by: Chris Curvey | last post by:
Hi all, I've apparently tied myself up a bit using the logging package. In my project, I have a core set of model and controller classes that set up their logging using logging.fileConfig()....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.