This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Function call doubt

 
Sen George
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changing the line to

worked. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic