[thelist] document.write problems

Rory.Plaire at wahchang.com Rory.Plaire at wahchang.com
Wed Jul 18 11:47:20 CDT 2001


| Evolters,

I'm honored!
 
| I've been trying to create a dynamically generated form, with 
| some success.

Great!

| One small problem - how can I get document.write to write to the same
| document & not to create a new one?

It's tricky, at best, since you have to use the document.write function
whilst the document is being streamed. That means only as it is coming from
the server (or cache even -- depends on the browser). 

One thing you can try is to include hidden fields (say, hidden1) in a
separate form (para ejemplo, form2) on your page. 

In the places in your document where you need the new content, you have a:
document.write(form2.hidden1.value). 

Events (like clicking buttons, entering text in fields, etc.) can then call
functions which change the value of these fields, like this: 

function addNewField1()
{	form2.hidden1.value = "<input type='text' name='txtNewField1'>" }

When you then execute a history.go(0) [i.e. a refresh], the
document.write(form2.hidden1.value) displays the new value and your new
content appears.

A tolerable overview (if you don't mind loud colors) is here:
http://www.trans4mind.com/personal_development/JavaScript/docWrite3.htm .

A completely different, and I would venture to say more commonly used way
would be to use layers (DIVs in IE) and DHTML.

| Thanks,

Can only hope this helped,
<rory disposition="kindly" alt="8)"/>




More information about the thelist mailing list