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

Alert box Undefined

P: 23
My alert box gives "undefined' when i return some 'true or false'.Please solve my problem
Nov 11 '08 #1
Share this Question
Share on Google+
6 Replies


DrBunchman
Expert 100+
P: 979
Hi gowthamkg,

Can you show us the code you are using please.

Thanks,

Dr B
Nov 11 '08 #2

P: 23
Expand|Select|Wrap|Line Numbers
  1. alert(frmregistration('EmailId'));
  2.     if(frmregistration('EmailId')==false)
  3.     {
  4.  
  5.         return false;
  6.     }
  7.  
  8.  
  9. function frmregistration(sValidateUserAndEmailId)
  10. {
  11.  
  12.     var xmlHttp;
  13.     try
  14.   {
  15.   // Firefox, Opera 8.0+, Safari
  16.   xmlHttp=new XMLHttpRequest();
  17.   }
  18. catch (e)
  19.   {
  20.   // Internet Explorer
  21.   try
  22.     {
  23.     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  24.     }
  25.   catch (e)
  26.     {
  27.     try
  28.       {
  29.       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  30.       }
  31.     catch (e)
  32.       {
  33.       alert("Your browser does not support AJAX!");
  34.       return false;
  35.          }
  36.         }
  37.     }
  38.  
  39.     //get user entered city name
  40.     var txtname=document.getElementById('txtuname').value;
  41.     var strEmail=document.getElementById('txtemail').value;
  42.     if(sValidateUserAndEmailId=='ValidateUserName')
  43.     {
  44.         xmlHttp.open("GET","CommonHTTP.asp?name="+ txtname,true);
  45.     }
  46.     else if(sValidateUserAndEmailId=='EmailId')
  47.     {
  48.  
  49.         xmlHttp.open("GET","CommonEmailHTTP.asp?EmailId="+ strEmail,true);
  50.     }
  51.  
  52.     xmlHttp.send();
  53.     xmlHttp.onreadystatechange=function()
  54.     {
  55.      //if request has been entertained and response is returned from server
  56.      if(xmlHttp.readyState==4)
  57.      {
  58.       //document.getElementById('dvweather').innerHTML=xmlHttp.responseText;
  59.       //alert(xmlHttp.responseText);
  60.       if(xmlHttp.responseText=="Failed")
  61.       {
  62.         if(sValidateUserAndEmailId =='ValidateUserName')
  63.             {
  64.                 alert("This user already exist");
  65.  
  66.             }
  67.         else if(sValidateUserAndEmailId =='EmailId')
  68.             {
  69.                 alert("This Email already exist");
  70.             }
  71.         return false;
  72.       }
  73.       else
  74.       {
  75.         if(sValidateUserAndEmailId =='ValidateUserName')
  76.         {
  77.             alert("This user Does not exist");
  78.         }
  79.         return true;
  80.         //document.registration.action="CommonHTTP.asp";
  81.       }
  82.      }
  83.     }
  84.  
  85. }
Nov 11 '08 #3

DrBunchman
Expert 100+
P: 979
gowthamkg,

Please don't forget to wrap your code in CODE tags - it makes your posts much easier to read - and please read the Posting Guidelines if you have not done so already.

Which alert box is causing you the problem?

Dr B
Nov 11 '08 #4

P: 23
alert(frmregistration('EmailId'));.actually this function comes bottom, i have just added in the starting.
Nov 12 '08 #5

JamieHowarth0
Expert 100+
P: 533
Hi guys,

This thread has been moved to the Javascript forum as it is not a classic ASP-related question.

Many thanks,

codegecko
Moderator
Nov 12 '08 #6

acoder
Expert Mod 15k+
P: 16,027
The frmregistration function makes an Ajax request which is asynchronous and the callback function does the alerting anyway. So there's no need for an alert. Just call frmregistration instead.
Nov 12 '08 #7

Post your reply

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