This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Function call doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Function call doubt" Watch "Function call doubt" New topic

Function call doubt

Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
Iam exploring function calls in Javascript and here is a code sample.

The page gets loaded without errors but the function call does not work. Please help.
stef li

Joined: Jan 16, 2006
Posts: 27
just remove the "evt" in the
<input type="text" name="UserId" onfocus="displayName()">
<input type="password" name="pwd" onfocus="displayName()">

but you must remain the "evt" in the function.

This guy is so lazy!!!<br />There is nothing left!
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
It needs to be event in the event handler

when you add it to the element like this

The browser does it automatically;

If you do it with a closure, you need to specify the event

And in your function declaration function displayName( XYZ ){ you can name it abc, evt, foo, bar, etc. It does not matter. You also can use the arguments and get it that way. alert(arguments[0]);

[ October 14, 2008: Message edited by: Eric Pascarello ]
Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
Changing the line to

worked. Thanks.
I agree. Here's the link:
subject: Function call doubt
It's not a secret anymore!