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条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度