javascript - 如何覆盖表单中的 asp-action - Javascript
问题描述
我有一个这样的表单,我想使用 javascript 更改 asp-action,但下面的代码不会覆盖。我在这里做错了什么?
HTML
<form class="myform" id="myform" asp-action="Create" asp-controller="Users" method="get">
<button type="submit">
</button>
</form>
JS
document.getElementById('myform').addEventListener('submit', (e) => {
e.preventDefault();
this.action = 'Index';
this.submit();
});
解决方案
我会尝试使用setAttribute
,因为 asp-action 是 ASP 特定的参数。
this.setAttribute("asp-action","Index");
推荐阅读
- apache-flink - Flink:我们应该使用什么来代替命令行选项'-yt'?
- python - 替换 NaN 值
- windows-terminal - 阻止 Windows 终端显示当前目录
- game-physics - 使用坐标查找形状所属的节点
- web-applications - 如何关闭特定的 mdc 对话框
- google-cloud-storage - 访问 Ad Manager 存储分区中的数据
- python - Subtour 约束导致 docplex 中的警告
- swift - 在选取器中显示多个视图
- r - 如何绘制同一 DataFrame 中 3 个向量的百分比变化?
- apache-arrow - Apache 箭头 - 将序列化的 VectorSchemaRoot 读取到 C++