G
Geoff Cox
Hello,
I read that moving from one page to another normally destroys a
variable. The code below allows the variable "name" to be used in a
form on the second page. How does this happen? Or am I wrong?
Thanks
Geoff
I have put the whole code of the first page below - I can then use the
value of the name variable on the second page using IE v6. Now how is
that possible?!
Geoff
<HEAD>
<SCRIPT>
function prompter(button)
{
name=prompt('What\'s your name?',"Please enter your first and
last name here, eg Jane Green");
alert("Welcome "+name + " Now read how to answer the
questions and then move to the questions");
document.getElementById('move').innerHTML =
"<button ID='move' onclick='movetoquestions()'>Move to
questions</button>";
if (button.parentNode && button.parentNode.removeChild)
{
button.parentNode.removeChild(button);
}
}
function movetoquestions()
{
window.location.href="second_page.htm";
}
</SCRIPT>
</head>
<body>
<h2 align="center">Tests</h2>
<pre>
</pre>
<p align="center"><input type="button" value="Please give us your
name" onclick="prompter(this)"></p>
<h3 align="center">How to answer a typical question</h3>
etc etc
<SPAN ID="move"></SPAN>
</body>
</html>
I read that moving from one page to another normally destroys a
variable. The code below allows the variable "name" to be used in a
form on the second page. How does this happen? Or am I wrong?
Thanks
Geoff
I have put the whole code of the first page below - I can then use the
value of the name variable on the second page using IE v6. Now how is
that possible?!
Geoff
<HEAD>
<SCRIPT>
function prompter(button)
{
name=prompt('What\'s your name?',"Please enter your first and
last name here, eg Jane Green");
alert("Welcome "+name + " Now read how to answer the
questions and then move to the questions");
document.getElementById('move').innerHTML =
"<button ID='move' onclick='movetoquestions()'>Move to
questions</button>";
if (button.parentNode && button.parentNode.removeChild)
{
button.parentNode.removeChild(button);
}
}
function movetoquestions()
{
window.location.href="second_page.htm";
}
</SCRIPT>
</head>
<body>
<h2 align="center">Tests</h2>
<pre>
</pre>
<p align="center"><input type="button" value="Please give us your
name" onclick="prompter(this)"></p>
<h3 align="center">How to answer a typical question</h3>
etc etc
<SPAN ID="move"></SPAN>
</body>
</html>