Hi,
I have a form with a text box. Next to the text box is a span that I've called Title2 and it starts with a ? in. The idea is when you start typing it changes from a ? to 'OK'.
Eventually there will be lots of of these so I want to have a function that handles it. I am calling the function as follows:
And my checkData function looks like this:
However I am getting an error that NameOfSpan is undefined. However if I output some data using my validate.asp script it is definitely getting the NameOfSpan value.
Any ideas?
Thanks very much
Ed
I have a form with a text box. Next to the text box is a span that I've called Title2 and it starts with a ? in. The idea is when you start typing it changes from a ? to 'OK'.
Eventually there will be lots of of these so I want to have a function that handles it. I am calling the function as follows:
Code:
onKeyUp="checkData(this.value, '1', 'Title2')"
And my checkData function looks like this:
Code:
var xmlhttp
function checkData(DataTyped, ValidationType, NameOfSpan)
{
if (DataTyped.length==0)
{
document.getElementById(NameOfSpan).innerHTML="";
return;
}
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support XMLHTTP!");
return;
}
var url="validate.asp";
url=url+"?DataTyped="+DataTyped+"&ValidationType="+ValidationType+"&NameOfSpan="+NameOfSpan;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById(NameOfSpan).innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
However I am getting an error that NameOfSpan is undefined. However if I output some data using my validate.asp script it is definitely getting the NameOfSpan value.
Any ideas?
Thanks very much
Ed