/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Multiple Events In One Element

?
I apology for burdening you wonderful people after I’ve searched the tutorials & manuals with respect to using events to validate a form. I’ve been tracking the Javascript forum and it appears there’s a whole lot of confusion on multiple events on the same element.
If you direct to me to online documentation that treats this subject I’ll read it!
I hope the following examples will explain my questions:
(1) <input type=”text” id = ‘1’ tabindex = 1………onblur = “funct(—-) ; ”

This is the way I interpret the above: Due to an onload the focus is on this element & the element is waiting for the event to trigger by tab etc. When tab, the function is executed and returns to the HTML element which then executes the tabindex. I hope I said that corredtly?

(2) WHAT DOES THE SYNTAX LOOK LIKE FOR CODE INCLUDED AS PART OF
THE EVENT OR BETWEEN EVENTS?

IN THE FOLLOWING EXAMPLES, WHAT DOES THE DELIMITER DO FOR ME?
(3) Then I’ve seen this:
<input type=”text” id = ‘1’ tabindex = 1………on—- = “funct(—-) ; [ ; used as a delimiter] on—- = funct(—-) “

(4) Then I’ve seen this:
<input type=”text” id = ‘1’ tabindex = 1………on—- = “funct(—-) , [ , used as a delimiter] on—- = funct(—-) “

(5) Then I’ve seen this:
<input type=”text” id = ‘1’ tabindex = 1………on—- = “funct(—-) [ blank used as a delimiter] on—- = funct(—-) “

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991May 04.2008 — I didn't really fully understand the question, but I think this answers it. When you are including event-handlers in the HTML it is done like this:[code=html]
<input type="text" onblur="javascript[; as delimiter between javascript statements]" onfocus="whatever;">[/code]
Copy linkTweet thisAlerts:
@Angry_Black_ManMay 05.2008 — i think part of the confusion is that you think "tabindex" is either an event or part of javascript proper. if so, this is incorrect. a programmer might define the tabindex order with the expectation that a program should execute in a specific order, but it doesnt directly have any syntactical relationship to javascript.

also, tabindex is not an event. it may determine the order of element focus, which in turn may trigger an event, but the two are essentially unrelated.

as for the question about "multiple events", there should be no confusion. elements routinely have multiple events. the main thing to recognize is that the javascript inside an event should be treated simply as the "result of an event", instead of the event itself. using that model, we see that this example only has two [COLOR="Red"]events[/COLOR]:

&lt;div [COLOR="Red"]onclick[/COLOR]="alert('hello');alert('world')" [COLOR="Red"]onmouseover[/COLOR]="alert('on');alert('mouse');alert('over')"&gt;sdfaasdf&lt;/div&gt;

however, each of those [COLOR="Red"]events[/COLOR] contains multiple javascript statements. ignoring what those statements actually (or could possibly) do, they are simply statements that are run when triggered by their corresponding event.

to have eliminated confusion about the proper delimiters used between each javascript statement inside an event, simply run the code and wait for errors. using commas as you noted in one of your examples is not proper javascript (in that context), and would error. whenever javascript is run on one line, you must have a semicolon to delimit the end of a statement. if you use multiple lines, you don't need a semicolon. your example #3 is the only syntax that would not create an error in inline javascript.
Copy linkTweet thisAlerts:
@KENDOLEVYauthorMay 06.2008 — Thank you for taking the time to respond! KENDOLEVY
×

Success!

Help @KENDOLEVY spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...