471,851 Members | 979 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

can't call this function

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. var flag=0;
  6.  
  7. callf()
  8.  {
  9.   if(flag == 0)
  10.    {
  11.     test()
  12.      {
  13.        alert("hi from if");
  14.      }
  15.    }
  16.  
  17. else
  18.   {
  19.     alert("hi from else");
  20.   }
  21.  }
  22.  
  23.  
  24.  
  25. </script>
  26.  
  27. </head>
  28. <body>
  29.  
  30.  <input type="text" onchange="callf();">
  31.  
  32. </body>
  33. </html>
  34.  
what's wrong with this code ??
nothing happens when i type into the text box..
Apr 30 '09 #1
2 1153
Dormilich
8,658 Expert Mod 8TB
@aashishn86
check out the Error Console!

callf() is not a function. functions are defined using the function keyword.

Expand|Select|Wrap|Line Numbers
  1. function callf() { // code comes here }
  2.  
  3. // alternatively
  4. var callf = function() { // code comes here }
Apr 30 '09 #2
acoder
16,027 Expert Mod 8TB
Two other problems:
1. test() is not defined.
2. It's called onchange, so it won't fire on key presses, but after the field loses focus and there's been a change.
Apr 30 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

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.