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!

Directly updating innerHTML via cgi return

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all;

Here's an interesting idea / question:

1) With CSS2 in both NS6 and IE 5.0 + , it's easy to manipulate HTML in a particualr object directly and to change it on the fly without hitting the server and without refreshing the page. If you aren't familiar with that, you can do it by sticking whatever HTML block you want to manipulate inside a DIV that has an ID, like this:

<DIV id=&quot;dynamicblock&quot;>
I'm some stuff you want to replace on the fly
</DIV>

Then, if you happen to have some javascript variable in which you have plugged something new, you can

document.getElementById(&quot;dynamicblock&quot;).innerHTML=yourvariable;

And poof!

OK, now the thing that is neat about that is that you can make major page alterations without refreshing the page.

What I would LOVE to do is to set the content of an identified object (as seen above) by poking something into it directly returned from the server. Something like this:

document.getElementById(&quot;dynamicblock&quot;).innerHTML =
Has anyone figured out a way to do something like this?

The problem is that I don't want to refresh the page the user is viewing every time I ask the server for some data. I have a CGI that peeks at a database delta table ( a change table). This table tells me what of some values have changed since the last time I happened to look at it. I use it to alter the display on the client side based on a changing state an the server. The CGI returns what has changed, and the client manipulates the display via javascript to reflect the changes. NOW, One way to make all this invisible to the user is to return that information into a tiny frame that the user can't really see (as an array, for example) and to manipulate the view frame based on that data. But that's a cumbersome approach. It would be much much nicer if I could directly target an object ID with the results of the server query.

Anyone know of a way to do that?

Thanks :)
 
How about having a &quot;invisible&quot; popup window that you use to &quot;run&quot; the cgi, and have the cgi return a VERY minimal &quot;page&quot; which contains the javascript code to update the innerHTML on it's opener. For example, the cgi program could return this:
Code:
<html>
<head>
<script>
self.opener.document.getElementById(&quot;dynamicblock&quot;).innerHTML=yourvariable;
</script>
</head>
<body>
</body>
</html>
To make the popup &quot;invisible&quot;, just position it off the screen when you open it.

Just an idea. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top