Forum Moderators: coopster

Message Too Old, No Replies

javascript, php

refresh values in textbox received from cgi script

         

utrosa

11:05 am on Nov 29, 2004 (gmt 0)

10+ Year Member



I'm trying to refresh textboxes with values received from cgi scripts.

I use php code within javascript that calls cgi scripts. So textboxes are refreshed every second with values received from cgi script.

Example (javascript and php code set value in textbox received from cgi script):

document.getElementById("id11").value= <? echo system(/home/apache/cgi-bin/id11.cgi');?>;

But textboxes are always refreashed with values received from cgi scripts when they are called for the first time. If cgi script returns value 5 when it is called first time and written in textbox, then this value (5) will be written in textbox every next second. Correct value is written again in textbox when I refresh web page, but only when cgi is called for the first time. From there on the old value is written in textbox every next second again.

How to solve this problem?

dcrombie

11:34 am on Nov 29, 2004 (gmt 0)



The CGI-script runs on the web server, and only when the page is actually requested by the browser. So you can't 'refresh' the CGI values without making another request to the server.

There's no 'clean' way to do it with JavaScript but you might be able to use Java or a similar language to keep open the connection after the page has loaded.

coopster

3:02 pm on Nov 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, utrosa.

As dcrombie said, you need to hit the server again to get refreshed data because HTTP is a stateless protocol. A quick search will turn up plenty of reading on that topic.

utrosa

10:43 pm on Nov 29, 2004 (gmt 0)

10+ Year Member



Thank you guys. I found answer to my question. Some guy suggests iframes. I hope this will work for me too.