Jump to content

Why the Ajax code below in ajax.js causes everything on the form to not function


jd2007

Recommended Posts

Why the Ajax code below in ajax.js causes everything on my page to not function ? pls help...

 

var a=0;
var b=0;
var c=0;
var d=0;
var e=0;
var f=0;

function check1()
  {
     if (document.getElementById("text1").value == "")
     {
      a=0; 
      document.getElementById("alert1").style.visibility="visible";
     }
     else
     {
      a=1;
      document.getElementById("alert1").style.visibility="hidden";
     }
  }

function check2()
  {
   if (document.getElementById("text2").value == "")
     {
      b=0;
      document.getElementById("alert2").style.visibility="visible" 
     }
     else
     {
      b=1;
      document.getElementById("alert2").style.visibility="hidden";
     }
  }

function check3()
  {
    if (document.getElementById('text3').value == "")
     {
      document.getElementById("alert3").style.visibility="visible";
      c=0; 
     }
     else
     {
       document.getElementById("alert3").style.visibility="visible";
       c=1;   
     }
  }

function check4()
  {
    if (document.getElementById('text4').value == "")
     {
      document.getElementById("alert4").style.visibility="visible";
      d=0;
     }
     else
     {
      document.getElementById("alert4").style.visibility="hidden";
      d=1;
     }
  }

function check5()
  {
     if (document.getElementById('text5').value == "")
     {
      document.getElementById("alert5").style.visibility="visible";
      e=0;  
     }
     else
     {
      document.getElementById("alert5").style.visibility="hidden";
      e=1;
     }
  }

function check6()
  {
     if (document.getElementById('text6').value == "")
     {
      document.getElementById("alert6").style.visibility="visible";
      f=0; 
     }
     else
     {
       if (document.getElementById('text6').value==document.getElementById('text5').value)
       {
       document.getElementById("alert6b").style.visibility="hidden";
       f=1; 
       }
       else
       {
       document.getElementById("alert6b").style.visibility="visible";
       f=-1;
       }   
     }
  }
  
var xmlHttp;
var xmlHttp2;

function GetXmlHttpObject()
{
var xmlHttp=null;
var xmlHttp2=null;
try
  { 
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  xmlHttp2=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
return xmlHttp2;
}

function checkUsername(str)
{
if (str.length==0)
  { 
  document.getElementById("alert4").style.visibility="visible";
  return;
  }
else
  {
document.getElementById("alert4").style.visibility="hidden";
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="username.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged();
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} 
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("alertuse").innerHTML=xmlHttp.responseText;
}
}

function signup(stra, strb, strc, strd, stre)
{
xmlHttp2=GetXmlHttpObject()
if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url2="signingup.php";
url2=url2+"?a="+stra+"?b="+strb+"?c="+strc+"?d="+strd+"?e="+stre"?f="+a+"?g="+b+"?h="+c+"?i="+d+"?f="+e;
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url2,true);
xmlHttp2.send(null);
} 

function stateChanged2() 
{ 
if (xmlHttp2.readyState==4)
{ 
document.getElementById("www").innerHTML=xmlHttp2.responseText;
}
}

 

this is the form:

 

<html>
<head>
<title></title>
<script src="ajax.js" type="text/javascript"></script>
</head>
<body>
<label for=first id=first>First Name :</label> <input type="text" id="text1" onchange="check1();" />
<span id="alert1" style='visibility:hidden;'><< Please fill your first name in this field.</span><br><br>

<label for=last id=last>Last Name :</label> <input type="text" id="text2" onfocus="check1();" onchange="check2();" />
<span id="alert2" style='visibility:hidden'><< Please fill your last name in this field.</span><br><br>

<label for=email id=email>E-mail :</label> <input type="text" id="text3" onfocus="check1(), check2();" onchange="check3();" />
<span id="alert3" style='visibility:hidden'><< Please fill your email in this field.</span><span id="alert3b" style='visibility:hidden'><< Your email ain't valid. Please enter a valid e-mail.</span><br><br>

<label for=username id=username>Username :</label> <input type="text" id="text4" onfocus="check1(), check2(), check3();" />
<span id="alert4" style='visibility:hidden'><< Please fill your desired username in this field.</span>
<span id="alert4b" style='visibility:hidden'><< Username taken. Please choose another username.</span><br><br>

<label for=pass id=pass>Password :</label> <input type="password" id="text5" onfocus="check1(), check2(), check3(),   checkUsername(document.getElementById('text4').value);" onchange="check5();" />
<span id="alert5" style='visibility:hidden'><< Please fill your desired password in this field.</span><br><br>

<label for=cpass id=cpass>Confirm Password :</label> <input type="password" id="text6" onfocus="check1(), check2(), check3(), check4(), check5();" /><span  id="alert6a" style='visibility:hidden'><< Please confirm your password.</span><span id="alert6b" style='visibility:hidden'><< Passwords don't match.</span><br><br>
<span id=alertuse></span> <span id=www></span>
<input type="submit" name="signup" value="Sign Up" onmouseover="signup(document.getElementById('text1').value,  document.getElementById('text2').value, document.getElementById('text3').value, document.getElementById('text4').value, document.getElementById('text6').value);" />


<div id=confirm style='visibility:hidden;'>
Please enter the confirmation code in the box below.<br><br>
Confirmation Code: <input type="text" name="ccode" />  <input type="button" value="Confirm" onclick=''/>
</div>

</body>
</html>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.