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
2 Answers
Reset to default 3That 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
评论列表(0条)