I have made a program in which the user will enter the name and the time will automatically display in the other text box. But the problem it is not showing the output as needed. It is displaying the same text as written in the asp file.
Following the code.
[HTML]
<html>
<body>
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
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;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","time.asp",true);
xmlHttp.send(null);
}
</script>
<form name="myForm">
Name: <input type="text" onkeydown="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form>
</body>
</html>[/HTML]
ASP file
Expand|Select|Wrap|Line Numbers
- <%
- response.write(time)
- %>