When visitors visit my page, I want them to prompted with a box, ask their name, and use that name in text. I created a script like this:
function askname() {
var x=prompt("What is your name?","");
}
I placed that script between the head tags. Then, I write <body onload="askname()">. The box prompted successfully.
Now, I want to use that 'x' in text. First, I just wrote
<script type="text/javascript">document.write(x)</script>
But it does not work at all! Is there another method to do this? I plan to not using any javascript library, though. So I beg your help. Sorry if this is kind of stupid question, I'm newbie in JS. And sorry for my bad english, too...