Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2003
    Location
    Near Stevie Peele
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question A basic name prompt

    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!
    If CON is the opposite of PRO, then what's the opposite of PROGRESS?

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <!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>
    Last edited by fredmv; 10-11-2003 at 05:38 AM.
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #3
    New Coder
    Join Date
    Sep 2003
    Location
    Near Stevie Peele
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow that was quick Fred, thank you
    If CON is the opposite of PRO, then what's the opposite of PROGRESS?

  • #4
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're welcome.
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #5
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Doesn't that create a <marquee> tag? There are better ways of doing that, as marquee is depreciated
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #6
    New Coder
    Join Date
    Sep 2003
    Location
    Near Stevie Peele
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any other ways would be helpful as well, but until then I'll just stick with Fred's way. Go fred
    If CON is the opposite of PRO, then what's the opposite of PROGRESS?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •