Click to See Complete Forum and Search --> : User name to appear on all of my webpages


reyjking1975
04-11-2003, 09:17 AM
Hello i am kinda new to this whole javascript, and i have a question for anyone: i put a some javascript code on my webpage, so that before my first page opens up you get a popup box saying Please enter name: after they enter their name, the page loads and they see their name on my webpage....

my question is there any script out there to have the peoples name automatically show up on all of my other pages after they sign in just once.......

i dont want them to keep on getting the popup box saying enter name: when they enter the different pages on my site???

please any help will be greatly appreciated
thanks:)

here is the code i used:

<script>

var whatName=prompt("Please type in your name:","");
function doName(theName){
if ((whatName != "")&&(whatName !=null)){
// you can modify this as needed
// this is the message if a name is typed in
document.writeln("Hello "+whatName+"!")
}else{
// you can modify this as needed
// this is the message if a name is *not* typed in
document.writeln("Hello Guest!")
}
}

doName(whatName);

</script>

khalidali63
04-11-2003, 09:33 AM
you can forward the name to the next page.

1,in the page where you get the name
write this code to go to next page
<a href="javascript:nextPage();">Next Page</a>

now in this pages javascript code section define this method
function nextPge(){
window.location.href="nextPage.html?"+userName
}

And once on the next page if you only have name parameter tha you can get using this

userName = window.location.search

Hope this helps

Cheers

Khalid

reyjking1975
04-11-2003, 09:51 AM
hey thanks i gonna try it tonight, thanks again:)

reyjking1975
04-11-2003, 10:17 AM
this is both of my pages Page 1 and Page 2

PAGE #1 SCRIPT:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<a href="javascript:nextPage();">Next Page</a>

<script>

var whatName=prompt("Please type in your name:","");
function doName(theName){
if ((whatName != "")&&(whatName !=null)){
// you can modify this as needed
// this is the message if a name is typed in
document.writeln("Hello "+whatName+"!")
}else{
// you can modify this as needed
// this is the message if a name is *not* typed in
document.writeln("Hello Guest!")
}
}

doName(whatName);
function nextPge(){
window.location.href="nextPage.html?"+userName
}

</script>
<a href="page2.html">click here to next page </a>
</body>
</html>


PAGE #2 SCRIPT:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<SCRIPT>
function nextPge(){
window.location.href="nextPage.html?"+userName
}
userName = window.location.search
</SCRIPT>
<body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>
<p align="center"><b>PAGE #2</b></p>
</body>
</html>

is there something wrong that i typed in....