PDA

View Full Version : Can some help me with this PLEASE


gregd
10-19-2009, 09:36 AM
All the other browsers don't seem to have error for this code except IE. The error on page read:

Message: Object expected
Line: 6
Char: 3
Code: 0

Here is the code:


function doWork(){
var userName = document.getElementById('User_ID').value;
if(userName.length < 8){
document.getElementById('availability').innerHTML = "User ID is too short!";
exit();
}

httpObject = getHTTPObject();

if (httpObject != null) {
httpObject.open("GET", "../php-lib/check_username_availability.php?user=" + userName, true)
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
function setOutput(){
document.getElementById('availability').innerHTML = 'test2';
if(httpObject.readyState==4){

document.getElementById('availability').innerHTML = 'test3';
var response = httpObject.responseText;

if(response > 0){
//not available
document.getElementById('availability').innerHTML = "User ID is not Available!";
}
else{
//available
document.getElementById('availability').innerHTML = '<p style="color:#33AA55;">User ID is Available!</p>';
}
}
}

function getHTTPObject(){
if (window.XMLHttpRequest){ return new XMLHttpRequest(); }
else if (window.ActiveXObject){ return new ActiveXObject("Microsoft.XMLHTTP"); }
else {
alert("Your browser does not support AJAX.");
return null;
}
}


Thank you in advance.