表格中自动保存按钮前的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>

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>

This is the sample html code you need to change.

<form name="myForm" id="myForm" 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>
</form>

Below code the form will be automatically post back to server after 2 seconds to the action method. make sure this code will be executed after the data will fetch from DTRSearch.php else it will send blank value to the server. You can use this on submit click or you can directly make function and call this after data is fetched.

setTimeout(function() {
        document.forms["myForm"].submit();
    }, 2000);

</div>