[英]onclick having href in a submit button
I want to change page when I click the update/submit button. 当我单击更新/提交按钮时,我想更改页面。 Here is my submit button code:
这是我的提交按钮代码:
<td width="8%"><input type="submit" name="submit" value="Update" onclick="??????????"></td>
I place a question mark where I want the link/href would be place. 我在要链接/ href的位置放置一个问号。 Or you can suggest other methods to do that when I click update button it directs me to another php file.
或者,您可以建议其他方法来执行此操作,当我单击“更新”按钮时,它会将我定向到另一个php文件。 Thanks!
谢谢!
No onclick
needed. 无需
onclick
。 onclick
is for executing JS. onclick
用于执行JS。 This is done by setting action
attribute for <form>
. 这是通过为
<form>
设置action
属性来完成的。
<form method="POST" action="anotherPHPFile.php">
<input type="submit" name="submit" value="Update">
</form>
After clicking on button, you will be redirected to anotherPHPFile.php
. 单击按钮后,您将被重定向到
anotherPHPFile.php
。
Do like this! 这样吧!
function redirect(e){ //If you want to check something here can prevent defualt button action // e.preventDefault() //now do your action. // similar behavior as an HTTP redirect window.location.replace("http://stackoverflow.com"); // you can also use this line to do similar behavior as clicking on a link // window.location.href = "http://stackoverflow.com"; }
<input type="submit" name="submit" value="Update" onclick="redirect()">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.