Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic update 1

Status
Not open for further replies.

afx

Programmer
Mar 4, 2004
27
CA
I have a page with a 1 row x 3 column table.

In the center cell I have some PHP that sends commands through a socket to a unix box that runs a process that generates a PDF.

I would like the right-hand cell to automatically update with the text lines stating what command is being run next.

Starting process ... done
Checking directory ... done
Next command ...

My question is: is this possible using JavaScript? Or should I be using Flash or even Dreamweaver?

regards
Mark H., AFX
 
it is possible, but i would suggest flash (its just not woth it doing it in javascript)...

Known is handfull, Unknown is worldfull
 
JavaScript would be perfect for this job - no need for Flash at all.

If all you want to do is have a log / history of commands you are sending, then you can easily achieve this with JS.

Every time you go to send a command, you can add it to the right-hand cell using standard DOM methods, like createTextNode, and appendChild.

Say your right-hand cell has an ID of "myLogWindow", you could use:

Code:
var logEntry = document.createTextNode('Command information here...');
document.getElementById('myLogWindow').appendChild(logEntry);

to add the entry to it.

Of course, you can add any elements... so you could add your log entry within a span or div, and style it up accordingly.

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Incidentally...

My question is: is this possible using JavaScript? Or should I be using Flash or even Dreamweaver?

JavaScript and Flash are technologies. Dreamweaver is simply an application that lets you create code. You cannot write applications in Dreamweaver - it is not a language in its own right. You can, however, write code using Dreamweaver.

Hope this clears up any confusion,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Hi BillyRayPreachersSon(Dan)

Thanks for the info.

I a still having a problem: I have a form with a file/browse/submit structure. On pressing submit it calls the current page again and runs the appropriate code (it processes the file - which is correct). However, my right-hand panel doesn't update at all.

In the initial call the page calls a layout.php which sets up the basic layout of the page and the table with the following in the right-hand cell:
<td id="progress"> </td>
<script language="JavaScript" type="text/javascript">
var newText = document.createTextNode("STATUS: ready")
document.getElementById("progress").appendChild(newText)
</script>

Then when the processing code gets called it executes:
...
$msg = 'File: '.$file['name'][$i] (...etc);
?><script language="JavaScript" type="text/javascript">
<!--
var logEntry = <?php 'File: '.$file['name'][$i] (...etc)?>
document.getElementById('progress').childNodes[0].nodeValue = logEntry
-->
</script><?php ...

I've made sure that there is only 1 tag <td> that has the id="progress" and I just can't see what's wrong. Would you or anybody please put me out of my misery! Thanks in advance.

regards
Mark H., AFX
 
Hi Dan

I got it working - sort of! It now runs without giving me any errors in either IE or Firefox. However, although the last line of text to be output using the javascript "document.getElementById("progress").childNodes[0].nodeValue = mytext" (which replaces the previous value of the node each time), it doesn't display them as each step is processed. It seems to wait until it's all done then just display the page once everything has completed.

Is there a way to make it display each time there an update to the node?

regards
Mark H., AFX
 
Yes - use the code I gave you in my first post. The "append" in "appendChild" should be a subtle hint that it will not overwrite what is there, choosing to append instead.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top