Click to See Complete Forum and Search --> : how to input user's name into more than 1 spot?


trentfred
06-06-2003, 07:43 PM
ok iknow if you put this script (<script language="VBScript"><!--Dim Name
Name=InputBox("Whats your name?")document.write Name-->
</script>) in where you want the name the user inputs in the box to be in that spot but is there a way to have that script in one spott and have their name appear in a different spot, because if you put that script in multiple areas to getthe same name in that area they will have to put their nam in multiple times.

Oh yeah i will give an example of wha dont want :
Hello, <script language="VBScript"><!--Dim Name
Name=InputBox("Whats your name?")document.write Name-->
</script> welcome to my site. My best friend is <script language="VBScript"><!--Dim Name
Name=InputBox("Whats your name?")document.write Name-->
</script>. I know that yor name is: <script language="VBScript"><!--Dim Name
Name=InputBox("Whats your name?")document.write Name-->
</script>
---------------------------------------------------------------------
But then they would have to input their name iin 4 times... i want to have their nam in all those spots without requiring the visitor to write their nam 4 times.

Thanks

Charles
06-06-2003, 07:55 PM
In JavaScript that would be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<script type="text/javascript">
<!--
var userName = prompt('What is your name', '');
if (!userName) userName = 'you';
// -->
</script>
<p>Mist
<script type="text/javascript">
<!--
document.write (userName);
// -->
</script>
<noscript>you</noscript>
stoborhiem stigibront, te
<script type="text/javascript">
<!--
document.write (userName);
// -->
</script>
<noscript>you</noscript>
opopl opapam puplatis. Spipopheus, rilispum ul rhepodrem gefanis.</p>

And note the use of the NOSCRIPT element to provide a default value for the 13% of users that do not use JavaScript.

trentfred
06-06-2003, 09:56 PM
ok thanks for thanks for that.. but when i tried that and put my name in it had a ton of other words around... i played with it for a little bit and dfeleted parts and it now works ok.. also played with that and got the question answered.. only one more thing.. i dont know since i deleted stuff if it will work for everybody.. well here is my new script
<script type="text/javascript">
<!--
var userName = prompt('What is your name', '');
if (!userName) userName = 'you';
// -->
</script>
<script type="text/javascript">
<!--
document.write (userName);
// -->
</script>
<noscript>you</noscript>
<script type="text/javascript">
</script>
<noscript>you</noscript>


then to put the name they put in the box in a different spot i took this part out of the script </script>
<script type="text/javascript">
<!--
document.write (userName);
// -->
</script> and put it where i wanted it.

any problems please tell! thanx