This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Function call doubt" Watch "Function call doubt" New topic
Author

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
Greenhorn

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
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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]);

Eric
[ 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: http://aspose.com/file-tools
 
subject: Function call doubt