...

View Full Version : Updating textbox without refreshing page



dopamine444
07-04-2011, 02:18 PM
Hi everyone, I'm new to html and programming in general and have a query.

I've got a user interface written in html, with various parameters for iperf in various textboxes. When the submit button is pressed, I call a .php file which takes the parameters and passes them to a java programme which runs iperf.

Using a form action pointing to the .php file, I can call the .php file and get the output (the data collected by iperf) to be printed to the screen, it just isn't in real time and refreshes the page completely. How would I redirect this output to a textbox on the original page?

I was thinking about calling a javascript function upon submission of the form which would start an XMLHttprequest, but can't seem to get this to work...

Current code which doesn't seem to do anything:


<head>
<script language="javascript" type="text/javascript">
function ajaxFunction()
{
var ajaxRequest

try
{
ajaxRequest = new XMLHttpRequest();
}
catch (e)
{
try
{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
return false
}
}

ajaxRequest.onreadystatechange = function()
{
if (ajaxRequest.readystate == 4)
{
this.iperfClientParameters.results.value = ajaxRequest.responseText;
}

};

ajaxRequest.open("GET","iperfRunningFile.php",true)
ajaxRequest.send(null);
}
</script>
</head>
<body>
<form name="iperfClientParameters" onSubmit="return ajaxFuntion()" method="get">
//form contents
</form>
</body>


Thanks in advance for any responses.

vikram1vicky
07-04-2011, 02:27 PM
You should post this in javascript section instead of HTML/CSS..

Still I ll try to answer it soon :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum