如何自动发布提交?

I want to post automatically when the input value is written. Please can you help? The form is as follows:

<form method="post" action="searchresults.php">
     <input type="text" name="searchresult">
     <input type="submit">
</form>

This should be done with jQuery.

$('#toPost').keyup(function(){
  $('#sub').click();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post" action="searchresults.php">

<input type="text" name="searchresult" id="toPost">
<input type="submit" id="sub">
    
</form>

</div>

I would recommend to work additionally with a simple Timeout. So, it will automatically submit when you are done with writing - with the code above (from patwoj98) you could just write 1 letter until submit. If you want more than 1 letter for your input, then i would do it like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        var srt = null;
        $("input[type=text]").on("keyup", function() {
            srt != null && clearTimeout(srt);
            srt = setTimeout(function(){
                $("input[type=submit]").click();
            }, 500);
        });
    });
</script>
<form method="post" action="searchresults.php">
    <input type="text" name="searchresult">
    <input type="submit">
</form>

this would be the way I would realize this.