I have a form like this and i want to change the asp-action using javascript but the code below does not overwrite. What could i be doing wrong here ?
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.