JavaScript problem. Document.writeln writes to new window, not the

T

Tomas

I have this simple function:

<SCRIPT LANGUAGE="JavaScript"><!--
function paper(){
document.writeln(document.FrontPage_Form1.paper_brand);
}
//--></SCRIPT>

tha is called by:

<input name="paper_brand" size="20" onBlur="paper()" style="text-align:
center; float:left" readonly>

The idea is to extract the entry in "paper_brand" and turn it into a header
further down on the page. If someone enters a certain paper type into the
textbox there will be a section that discusses this particular paper.

The function ddoes extract the paper entry, but writes it to a new page, not
the current one where the paper_brand field is.

???

Best,

Tomas
 
S

Steve Easton

document.writeln
should be
document.write

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
T

Tomas

Hi Steve,

I have tried both document.writeln and document.write, and did it again when
I saw your post. Makes no difference. A new page is opened and the correct
paper brand is written in unformated text at the top of the page.

Any other suggestions?

Best,

Tomas

"Steve Easton" skrev:
 
T

Tomas

Hi Steve,

I have tried both document.writeln and document.write, and did it again when
I saw your post. Makes no difference. A new page is opened and the correct
paper brand is written in unformated text at the top of the page.

Any other suggestions?

Best,

Tomas

"Steve Easton" skrev:
 
T

Tomas

I must correct my observation.

It is not a new page, but the same old one (the correct one). But.., the
page is cleaned of everything else but the printer name. Where did the rest
go?

"Tomas" skrev:
 
S

Steve Easton

ok, I took another look.
It should be document.all not document.write, but you have reference the name in document.all and
then also add innerHTML

document.all.FrontPage_Form1.formfield name.innerHTML = "<paper_brand>";

hth
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
J

Jon Spivey

Hi Tomas,

If you use document.write() it will clear the page. You'd need to put an
empty div on the page where you want the text to appear then write the text
to the div, eg
<div id="Text"></div>
<input
onclick="if(document.getElementById)document.getElementById('Text').innerHTML
= this.form.paper_brand.value;" value="....
 
T

Tomas

Jan,

That does indeed work, but just one more thing. Can I avoid the line break?

Now the text reads

"About paper:
Epson"

and it should be "About paper: Epson".

When nothing is entered in the paper_brand field it should only say "About
paper:"

I also need to put another <id tag since the final text should read

"About paper: Epson Photo Paper Glossy", where Epson comes from one field
and Photo Paper Glossy from another.

Best,

Tomas

"Jon Spivey" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top