dongxizhe9755 2017-06-08 02:13
浏览 27
已采纳

表格中自动保存按钮前的2秒间隔

Can I Make a 2 second interval before the auto-save perform? this code shows my webpage with a single textbox in it, and it auto show my DTRSearch.php result. This code is working perfectly.

<div id="search">
<input type="text" placeholder="Scan" id="t1" name="t1" onkeyup="aa();" 
autofocus/></div>

<script type="text/javascript"> 
function aa(){
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","DTRSearch.php?
nmnm="+document.getElementById("t1").value,false);
xmlhttp.send(null);
document.getElementById("searchdiv").innerHTML=xmlhttp.responseText;
document.getElementById("searchdiv").style.visibility='visible';
}
</script>
<div id="searchdiv" style="visibility:hidden; position:absolute">
</div>

DTRSearch.php it query a single row, this a simple form with a submit button, i want this form to perform an auto-save but before that it should show the form for 2 second

<form action="GetDTRSearch.php" method="get">
        <input type="text" value="<?php echo  $id_number;>" name="ID_Number" /><br />
        <input type="text" value="<?php echo  $fullname; ?>"name="Fullname" /><br />
        <p class="Ok"><input type="submit" value="Click Confirm" /></p>
  • 写回答

2条回答 默认 最新

  • dongyuan8469 2017-06-08 02:18
    关注

    Change the button to a simple button instead of an input type submit. Instead, add a click listener to the Submit button. The click listener should call a setTimeout() function to execute the form submission after 2 seconds.

    <form id="theForm" action="DTRSearch.php" method="get">
            <input type="text" value="<?php echo  $id_number;>" name="ID_Number" /><br />
            <input type="text" value="<?php echo  $fullname; ?>"name="Fullname" /><br />
            <p class="Ok"><button id="submitButton" value="Click Confirm" /></p>
    

    Then, assuming you have JQuery, add the following script:

    <script>
    $(document).ready(function() {
        $("#submitButton").click(function() {
            setTimeout(function() {
                $("#theForm").submit();
            }, 2000);
        });
    });
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题