【问题标题】:Access Javascript confirm result from classic asp访问 Javascript 确认来自经典 asp 的结果
【发布时间】:2014-09-04 18:04:49
【问题描述】:

我经常在 Classic ASP 中使用以下几行:

Response.Write "<script type=""text/javascript"">alert('Hello world')</script>"

但是我将如何为 Javascript 的确认语句做类似的事情并将结果返回到我的 vb 以询问结果?

Response.Write "<script type=""text/javascript"">confirm('Do you want to continue?')</script>"

显然是不够的。如果可能,我需要将结果分配给变量。

提前致谢。

【问题讨论】:

  • 你不能直接这样做。您必须使用 AJAX 将用户响应发送到服务器,然后可能在客户端代码中解析来自服务器的响应。

标签: javascript asp-classic


【解决方案1】:

我会使用 window prompt() 方法。以下是 W3 学校的示例:

<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 person = prompt("Please enter your name", "Harry Potter");
    if (person != null) {
        document.getElementById("demo").innerHTML =
        "Hello " + person + "! How are you today?";
    }
}
</script>

</body>
</html>

我已经使用了 W3 中的上述示例来捕获输入,但要获取值并提交到服务器:

document.getElementById("demo").value=
        person
document.submit()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    相关资源
    最近更新 更多