是否可以像这样传递提示框的输入值?
<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>
还是我必须使用表格?
是否可以像这样传递提示框的输入值?
<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>
还是我必须使用表格?
这是将返回的值传递prompt
给变量的正确方法。
var value = prompt("Please enter your name:", "Type your name here.");
如果您使用 javascript 创建一个窗口提示,它会要求您输入一些内容。所以你必须以这种方式实现你的代码才能得到提示,
<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>