Re: Write. function



I shall consider myself told off. I think my course is a bit ancient.
And its only fundementals. For instance I had never heard of innerHTML.
What is this actually doing?

cass27
Evertjan. wrote:
cass27 wrote on 31 aug 2006 in comp.lang.javascript:

I am just doing a course on Javascript and have begun to try out
different ideas. The effect I wanted was fro the user to click on a
graphic. Aprompt box would apprear asking their name and that imfo
would be transferred to the top of that page. However the users name
will only appear on a seperate page.

The code i am using (in brief) is as follows:

function getname()
{
myname = prompt("What is your name?","");
document.write("<font size 3>Welcome</font>");
document.write("<font size 3> </font>");
document.write(myname);

}

does anyone know how I cn get the users name to appear on the same page
(without using text box)?

Yes.

Maybe it cant be done using javascript.

A bad start thinking that. ;-)

[We should not do your homework by writing your code.]

You cannot do a document.write() after the page is loaded without
destroying both the page AND THE EMBEDDED JAVASCRIPT!
Your second document.write() has gone when the interpreter reaches it.

Look into .innerHTML to put your string into an <div> or <span>

Or, if you are up to it, use the DOM's childNode.

And do not use <font> nomore,
[you must have ancient course material!],
use css styles instead.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

.