Alert box Undefined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gowthamkg
    New Member
    • Sep 2008
    • 23

    Alert box Undefined

    My alert box gives "undefined' when i return some 'true or false'.Please solve my problem
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi gowthamkg,

    Can you show us the code you are using please.

    Thanks,

    Dr B

    Comment

    • gowthamkg
      New Member
      • Sep 2008
      • 23

      #3
      Code:
      alert(frmregistration('EmailId'));
      	if(frmregistration('EmailId')==false)
      	{
      
      		return false;
      	}
      
      
      function frmregistration(sValidateUserAndEmailId)
      {
      
      	var xmlHttp;
      	try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
      catch (e)
        {
        // Internet Explorer
        try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch (e)
          {
          try
            {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
          catch (e)
            {
            alert("Your browser does not support AJAX!");
            return false;
      		 }
      		}
      	}
      
      	//get user entered city name
      	var txtname=document.getElementById('txtuname').value;
      	var strEmail=document.getElementById('txtemail').value;
      	if(sValidateUserAndEmailId=='ValidateUserName')
      	{
      	    xmlHttp.open("GET","CommonHTTP.asp?name="+ txtname,true);
      	}
      	else if(sValidateUserAndEmailId=='EmailId')
      	{
      	    
      	    xmlHttp.open("GET","CommonEmailHTTP.asp?EmailId="+ strEmail,true);
      	}
      	
      	xmlHttp.send();
      	xmlHttp.onreadystatechange=function()
      	{
      	 //if request has been entertained and response is returned from server
      	 if(xmlHttp.readyState==4)
      	 {
      	  //document.getElementById('dvweather').innerHTML=xmlHttp.responseText;
      	  //alert(xmlHttp.responseText);
      	  if(xmlHttp.responseText=="Failed")
      	  {
      	    if(sValidateUserAndEmailId =='ValidateUserName')
      		    {
      				alert("This user already exist");
      				
      			}
      		else if(sValidateUserAndEmailId =='EmailId')
      		    {
      				alert("This Email already exist");
      			}
      		return false;
      	  }
      	  else
      	  {
      	    if(sValidateUserAndEmailId =='ValidateUserName')
      	    {
      			alert("This user Does not exist");
      		}
      		return true;
      		//document.registration.action="CommonHTTP.asp";
      	  }
      	 }
      	}
      	
      }
      Last edited by DrBunchman; Nov 11 '08, 02:49 PM. Reason: Added [Code] Tags - Please use the '#' button

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        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

        Comment

        • gowthamkg
          New Member
          • Sep 2008
          • 23

          #5
          alert(frmregist ration('EmailId '));.actually this function comes bottom, i have just added in the starting.

          Comment

          • JamieHowarth0
            Recognized Expert Contributor
            • May 2007
            • 537

            #6
            Hi guys,

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

            Many thanks,

            codegecko
            Moderator

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              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.

              Comment

              Working...