Is there any way to get what you type in to the prompt box below (a pseudo "username")to display on each page of a website after you submit it? I've done quite a lot of research, but I can't seem to find out how to do it. Of course, I may have been looking in all the wrong places, which might explain it *sweatdrop*

What I really would have liked is a password retrieval system, as I put in another thread, but my site isn't going to be on the net for a long time, so this will have to do. And I really don't have a members only area, so this option would be useless.

P.s. I've run a search and found nothing on this forum... hope this hasn't been posted before.

Philip M

05-28-2006, 10:34 AM

'name' is not a reserved word for a variable but it can cause problems in some situations - suggest you change it to usrname.

To achieve what you want you must set a cookie and then retrieve it for each page.
See:-

http://www.webreference.com/js/column8/name.html

http://www.w3schools.com/js/js_cookies.asp

There are other many examples of this - try:-

http://javascript.internet.com/cookies/n-browser.html
or
http://www.paulspages.co.uk/pcp/cookielib/index.htm

Note that if you had used Google and typed in 'javascript username cookie' you would have found all of the above right away. :D

dolthalion

05-28-2006, 10:50 AM

Thanks for the heads up! :thumbsup:

dolthalion

05-28-2006, 10:59 AM

Can this work without using a URL as a page destination? If so, what do I put?

Philip M

05-28-2006, 01:07 PM

Can what work?

dolthalion

05-28-2006, 01:15 PM

This script. I have tried it without setting the page destination to a URL, but it doesn't work. Is there a way to test it without using a server? The pages are not yet on the interent, and i have a feeling that's where I'm going wrong.

The pages you kindly linked to didn't provide much help with making a cookie that sends the "Username" to each page to display, though I did learn some handy tips. Is there a cookie that does this, please?

Also, usrname did not work. Thanks very much anyway :)

Philip M

05-28-2006, 03:28 PM

I have the feeling that you are way out of your depth and are trying in effect to learn to swim by correspondence course. However clear the instructions you still drown.

The idea is that you set the cookie on the index page (or the one where you ask the visitor to enter his username), and then read the cookie back ON EVERY SEPARATE PAGE where you want it to say "Hello UserName".

Of course usrname will work if you change each instance of 'name' to 'usrname'.

http://www.webreference.com/js/column8/name.html spells out very clearly how to set and retrieve a cookie containing the UserName. If you cannot follow (and copy) that then the whole subject is just too advanced for you at this stage.

To try to answer your other question, JavaScript is a client-side language and thus will work on the local machine regardless of whether you are connected to a server or not.

dolthalion

05-28-2006, 07:13 PM

Thanks Philip M.

I am way out of my league at this point in time. I have been learning JavaScript for a grand total of 3 days now. I still have no idea what anything does at this point.