html - 如何知道在表单中单击了哪个命令按钮
问题描述
我有一个包含 3 个命令按钮的表单。我想知道单击了哪个命令按钮并将值存储在会话变量中如何做到这一点。
我在会话变量中得到空值
<form method="post" name = "theform" >
<table>
<tr>
<td align="left" width="100%">
<input type="submit" name = "button" id ="idbutton1" value="Value1">
</td>
<td align="left" width="100%">
<input type="submit" name = "button" id ="idbutton2" value="Value2">
</td>
<td align="left" width="100%">
<input type="submit" name = "button" id ="idbutton3" value="Value3">
</td>
</tr>
</table>
</form>
Session("type")=Request.Form("button")
解决方案
您需要Request.Form("button")
在将其分配给会话变量之前检查它是否包含一个值,否则您将在Session("type")
每次页面加载时为其分配一个空字符串值。
if request.form("button") <> "" then Session("type") = Request.Form("button")
推荐阅读
- reactjs - 无法使仪表图表(使用 Recharts Pie)适合容器
- sql - 如何在 SQL 中到达去年的一周至今和本月至今?
- node.js - mongoose 聚合中无法识别的表达式“$toObjectId”
- javascript - Preact 不会在补液中替换 dom 元素?
- c++ - 打印 char* 指针的完整数据?
- azure-active-directory - 忽略 azure graph API 请求中的多因素身份验证
- html - 如何保持相同的位置
- ios - 如何使用 SwiftUI 检测当前设备?
- javascript - 在 ngrx/data 中使用存储值
- javascript - Jest 手动模拟未针对高阶函数执行