...

View Full Version : A basic name prompt



poolsharkboy599
10-11-2003, 04:12 AM
I am currently learning Javascript from one of your recommended sites as a tutorial. Concerning the example of a name prompt from http://home.cogeco.ca/~ve3ll/jstutor1.htm#temp , I had a question. Is there a way I could use that prompt (or any other) to get someone to type their name in, and then have it inserted into a marquee along with a little bit of other text?

--For example: If I wanted someone named John to type their name in, I'd want the page's marquee to display "Welcome to my site, John!"
-I'm new, so I would definitely appreciate any help or comments. Thanks! :thumbsup:

fredmv
10-11-2003, 04:30 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
//<![CDATA[
var user, marquee;

function init()
{
user = window.prompt("Name: ", "");
user = (user) ? user : 'Guest';

marquee = document.createElement("marquee");
marquee.setAttribute("style", "color: #0000ff; font-family: helvetica, serif; font-size: 20pt;");
marquee.innerHTML = "Welcome to my site, " + user + "!";

document.body.appendChild( marquee );
}

onload = init;
//]]>
</script>
</head>

<body>
<div></div>
</body>
</html>

poolsharkboy599
10-11-2003, 05:25 AM
wow that was quick Fred, thank you :p

fredmv
10-11-2003, 05:26 AM
You're welcome. :D

me'
10-11-2003, 03:34 PM
Doesn't that create a <marquee> tag? There are better ways of doing that, as marquee is depreciated ;)

poolsharkboy599
10-12-2003, 02:19 PM
Any other ways would be helpful as well, but until then I'll just stick with Fred's way. :D Go fred



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum