Jump to content

[SOLVED] ajax login/reg


sstangle73

Recommended Posts

when i use this script in firefox i love it it works great but in IE it says it fails no matter what.  ill give you where i think the problem is and if you need more just ask me =] thanks

 

function validate()
{
var tables; 

tables = document.getElementsByTagName('td')

for (i=0; i<tables.length; i++)//loop through all the <td> elements 
{
	// if the class name of that td element is rules check to see if there are error warnings
	if (tables[i].className == "rules")
	{
		//if there is a thank you or its blank then it passes
		if (tables[i].innerHTML == '<img src=\"/images/good.gif\" alt=\"Good\">' || tables[i].innerHTML == '' || tables[i].innerHTML == 'Check if you want to stay logged in')
		{
			tables[i].style.color = '#000000';//the color is changed to black or stays black
			tables[i].style.background = '#00ff18'
		}
		else
		{
			gErrors = gErrors + 1; //the error count increases by 1
			tables[i].style.color = '#FFFFFF';//error messages are changed to red
			tables[i].style.background = '#FF0000'
		}
	}
}

if (gErrors > 0)
{
	//if there are any errors give a message
	alert ("Please make sure all fields are properly completed.  Errors are marked in red and have a red X!");
	gErrors = 0;// reset errors to 0
	return false;
}
else return true;

}

 

http://test.stangle.info if you want to see the problem

 

-- edit --

 

i just thought as soon as i posted this mabie this is not a AJAX problem but a JS problem? i didnt even post any ajax in this thread?

Link to comment
Share on other sites

Your problem occurs in

 

Line: 61

Char: 6

Error: 'document.getElementByID(...)' is null or not an object

 

function handleHttpResponse() {
//if the process is completed, decide to do with the returned data
if (http.readyState == 4) 
  	{

  		sResults = innerHTML = http.responseText.split(","); //results is now whatever the feedback from the asp page was
	//whatever the variable glo_show's (usermsg for example) innerHTML holds, is now whatever  was returned by the asp page. 
    	document.getElementById(gShow).innerHTML = "";
	document.getElementById(gShow).innerHTML= sResults
  	}
}

 

Updated: Thats the code causing a problem so far.

Link to comment
Share on other sites

more of the code

 

function attachFormHandlers()
{
var form = document.getElementById('form1') 

if (document.getElementsByTagName)//make sure were on a newer browser
{
	var objInput = document.getElementsByTagName('input');
	for (var iCounter=0; iCounter<objInput.length; iCounter++)
	objInput[iCounter].onblur = function(){return validateMe(this);} //attach the onchange to each input field
}
form.onsubmit = function(){return validate();} //attach validate() to the form
}




/*validateMe is the function called with onblur each time the user leaves the input box
passed into it is the value entered, the rules (which you could create your own), and the id of the area the results will show in*/
function validateMe(objInput) {

sVal = objInput.value; //get value inside of input field

sRules = objInput.className.split(' '); // get all the rules from the input box classname
sRequired = sRules[1]; // determines if field is required or not
sTypeCheck = sRules[2]; //typecheck are additional validation rules (ie. email, phone, date)
    gShow = sRules[3]; //gShow is the td id where feedback is sent to.
  
//sends the rules and value to the asp page to be validated
http.open("GET", sUrl + (sVal) + "&sRequired=" + (sRequired) + "&sTypeCheck=" + sTypeCheck, true);
  
http.onreadystatechange = handleHttpResponse; 	// handle what to do with the feedback 
http.send(null);  
}


function handleHttpResponse() {
//if the process is completed, decide to do with the returned data
if (http.readyState == 4) 
  	{

  		sResults = innerHTML = http.responseText.split(","); //results is now whatever the feedback from the asp page was
	//whatever the variable glo_show's (usermsg for example) innerHTML holds, is now whatever  was returned by the asp page. 
    	document.getElementById(gShow).innerHTML = "";
	document.getElementById(gShow).innerHTML= sResults
  	}
}

im not sure what is wrong a little guidance would be great.

Link to comment
Share on other sites

Looks like you're not passing the variable "gShow" from function validateMe() to function handleHttpReponse()

 

http.onreadystatechange = handleHttpResponse; 	// handle what to do with the feedback 
http.send(null);  
}

should probably be:

http.onreadystatechange = handleHttpResponse(gShow); 	// handle what to do with the feedback 
http.send(null);  
}

And the function for that would have to receive it as well

function handleHttpResponse(gShow) {
//if the process is completed, decide to do with the returned data
if (http.readyState == 4) .... (etc)

just add the argument to the first line of the handleHttpResponse() function

 

And it should work.

Link to comment
Share on other sites

I might be out of the loop here, but I don't see any problems on the Register or Login page. Is the error you are talking about on the main page?

The reason you get that error is because you are using the javascript that is supposed to validate your form but you don't have any forms on that page. Just remove the script links and it will not give you the errors.

 

Also, the error is there in Firefox too, it just doesn't display it at the bottom left like IE does.

Link to comment
Share on other sites

heres the error on IE. . . on the login or its on the reg page.  it says that it fails even tho it passes. . . doing the same thing it will go through on firefox. . . . i know theres not a form on the index page i understand that its not a problem.

 

thanks

 

[attachment deleted by admin]

Link to comment
Share on other sites

Oh I see. Well, to get rid of the error, change your input type=submit button to just a button:

<button name="Submit" onclick="this.form.submit()" tabindex="4">Submit</button>

Something tells me that isn't the reason that IE is showing the alert when it shouldn't, but see if it changes anything.

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.