Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating textbox without refreshing page

    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:
    Code:
    <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.

  • #2
    Regular Coder
    Join Date
    Jul 2011
    Location
    India
    Posts
    496
    Thanks
    3
    Thanked 57 Times in 56 Posts
    You should post this in javascript section instead of HTML/CSS..

    Still I ll try to answer it soon


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •