javascript - Passing the input value of prompt boxes - Stack Overflow

Is it possible to pass a input value of prompt box like this?<script type="textjavascript"

Is it possible to pass a input value of prompt box like this?

<script type="text/javascript">
function prompt_box()
{
var naam=prompt("Please enter your name:","Type your name here.")
document.location = 'delete.php?target=' + naam;
}
</script>

Or do I have to use a form?

Is it possible to pass a input value of prompt box like this?

<script type="text/javascript">
function prompt_box()
{
var naam=prompt("Please enter your name:","Type your name here.")
document.location = 'delete.php?target=' + naam;
}
</script>

Or do I have to use a form?

Share Improve this question asked May 19, 2012 at 3:31 Visualizer7Visualizer7 3251 gold badge5 silver badges13 bronze badges 3
  • What do you mean by "this"? That code works fine for me. – Blender Commented May 19, 2012 at 3:38
  • pop-up can be intrusive for User experience... but hell it would work! – user753137 Commented May 19, 2012 at 3:39
  • 1 Have you even tried it yourself to see if it works? The answer is yes however. – LeeR Commented May 19, 2012 at 3:40
Add a ment  | 

2 Answers 2

Reset to default 3

That is the correct way of passing the value returned from prompt to a variable.

var value = prompt("Please enter your name:", "Type your name here.");

If you create a window prompt using javascript it will ask you to input something. So you have to implement your code in this way to get the prompt,

<html>
<body>

<p>Click the button to demonstrate the prompt box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
  var name = prompt("Please enter your name", "Micheal");
  if (name != null) {
    document.getElementById("demo").innerHTML =
    "Hello " + name + "! How are you today?";
  }
}
</script>

</body>
</html>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745435819a4627602.html

相关推荐

  • javascript - Passing the input value of prompt boxes - Stack Overflow

    Is it possible to pass a input value of prompt box like this?<script type="textjavascript"

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信