简体   繁体   English

一键触发按钮

[英]trigger to buttons with one single button click

I want to trigger to buttons by clicking on a third button. 我想通过单击第三个按钮来触发按钮。 One of my buttons submits data to a PHP file and the second one loads a bootstrap modal. 我的一个按钮将数据提交到PHP文件,第二个按钮加载引导程序模式。 When I run it, I feel that both are triggered, although the submit button works fine but the bootstrap modal disappears in a blink. 当我运行它时,我觉得两者都被触发了,尽管“提交”按钮可以正常工作,但是引导模式很快就消失了。 this is the code: 这是代码:

HTML HTML

<button onclick="submitdata(); showbootstrapmodal();">Click to Trigger the two other buttons</button>

<button id="submit" name="submit" type="submit" form="#myform"></button>
<button id="modal"  data-toggle="modal" data-target="#myModal"></button>

and here is the javascript code for the functions: 这是这些功能的javascript代码:

javascript JavaScript的

function submitdata(){
  document.getElementById('submit').click();
  return false;
}
function showbootstrapmodal(){
  document.getElementById('modal').click();
  return false;

Is there a flaw in my code? 我的代码有缺陷吗?

Try removing 'return false;' 尝试删除“返回假”; from submitdata() 来自submitdata()

function submitdata(){
  document.getElementById('submit').click();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM