drk7700 2016-11-30 21:55
浏览 9
已采纳

多提交按钮并输入密钥

i have 4 submit button,

<input type="submit" name="zmianapoz" value="Zmiana Ilości" id="dodaj1" /> 
<input type="submit" name="usunpoz" value="Usunięto" id="dodaj3" /> 
<input type="submit" value="Pobranie" id="dodaj2" /> 

and this is fourth:

<input type="submit" name="submit" value="Aktualizuj">

how can i do that if i press enter key=13 then work button fourth not first on web? i try with function onclick but probably i do something wrong

  • 写回答

1条回答 默认 最新

  • doumi1884 2016-11-30 22:02
    关注

    You should be able to trap the keydown event and trigger it yourself like so:

    document.addEventListener("keydown", function(event) {
      var enter = 13;
      if (event.keyCode === enter) {
        event.preventDefault();
        document.getElementById("dodaj4").click();
      }
    });
    document.getElementById("dodaj4").addEventListener("click", function() {
      alert("input 4 clicked!");
    });
    <input type="submit" name="zmianapoz" value="Zmiana Ilości" id="dodaj1" />
    <input type="submit" name="usunpoz" value="Usunięto" id="dodaj3" />
    <input type="submit" value="Pobranie" id="dodaj2" />
    
    <input type="submit" name="submit" value="Aktualizuj" id="dodaj4">

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题