This should be a simple question, the problem is I just have alot of holes in my knowledge so I'm not sure what I should be looking for. I've looked through some reference guides trying to find out what I'm missing, but realizing I wasn't too sure what to look for I figured I'd post here. Sorry if it's a dumb question.
So I know XHTML, CSS, Python, and am currently in the midst of learning javascript. I was fooling around trying to see what I can do more or less and the following lack of understanding occurred to me. Perhaps it's just something I haven't gotten to yet in my learning (reading the W3 tutorials to learn Javascript), but... figured it can't hurt to ask.
So sorry for the bit of introduction, but my question is after the button is hit, and a number entered, what is it returned to? How do I access this to, for example, print it on the screen?
Code:
<html>
<head>
<script type="text/javascript">
function getNumber()
{
x = prompt("Enter a number between 1 and 10","");
return x;
}
</script>
</head>
<body>
<input name="numberButton" type="Button" onclick="getNumber()" value="Number Button" />
Your favorite number is:
//Doesn't work, but I'm not sure why. x is terminated after closing the script I must assume, so what can be done to get the desired result?
<script type="text/javascript">
document.write(x);
</script>
</body>
</html>
Told you it was simple  . Thanks for the help!
|