[英]using multiple submit buttons in a form
I have a form with two button.I want to redirect to two different pages when i click these button.On the click event of both buttons i am executing a same function.I want that the function should be executed first then it should be redirected to respective page我有一个带有两个按钮的表单。当我单击这些按钮时,我想重定向到两个不同的页面。在两个按钮的单击事件上,我正在执行相同的 function。我希望首先执行 function 然后它应该被重定向到相应页面
you could change action of form on the fly during submitting (and answer varies depending on using jquery, pure javascript etc.)您可以在提交期间动态更改表单的操作(答案因使用 jquery、纯 javascript 等而异)
but I recommend using php for that task但我建议使用 php 来完成该任务
<input type="submit" value="Edit" class="spare" name="edit">
<input type="submit" value="Send" class="spare" name="send">
and then:接着:
if (isset($_POST['edit']))
...
elseif(isset($_POST['send']))
...
Try this:尝试这个:
<input type="button" value="Edit" class="spare" onclick="check('edit')">
<input type="button" value="Send" class="spare" onclick="check('send')">
Where with check()
will add the action to the form and then submit it:使用check()
将操作添加到表单然后提交:
function check(action){
var form = document.getElementById('formId');
form.action = 'http://needed/url/' + action;
form.submit();
}
Hope it solves your problem:)希望它能解决你的问题:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.