Domanda

I have a search box which filter Data from Sharepoint list developped with Javascript, here is the code :

<script type="text/javascript">   function RedirectUrl(){var tb = document.getElementById("tbSearch").value; if(tb != null){window.location.href="?FilterName=Full_x0020_Name&FilterMultiValue=*"+tb+"*";}return false;}</script>

<input type="text" id="tbSearch" />
<input type="button" id="btnSearch" value="search" onclick="return RedirectUrl();"/> 

I want that when I press the Enter key in the Textbox, it do the same thing as when I click on Search Button, Any suggestions ?

È stato utile?

Soluzione

Try this

    $('#tbSearch').keypress(function(event){
        var keycode = (event.keyCode ? event.keyCode : event.which);
        if(keycode == '13'){
           //Your Code that you want to execute or simply call the function RedirectUrl()
        RedirectUrl();
        }
    });

You need JQuery reference

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top