By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

can't call this function

P: 52
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
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
@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
Expert Mod 15k+
P: 16,027
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.