You need to sign in to do that
Don't have an account?
afoxmicroedge
Trigger html form button click event by pressing enter
Hello,
I have a html form with a text field and button. When button is clicked some JavaScript is executed that puts the search term in the URL. I wan't to trigger this button click event by user pressing enter as well...
<script type='text/javascript'> function insertSearchTerm(){ var searchTerm = document.getElementById("keyword").value; var url="https://c.na11.visual.force.com/apex/portalcasesearch?s="+searchTerm; window.location = url; return false; } </script>
<form name="frmSearch"> <input type="text" style="width:85%; height:25px;margin:0; padding: 0px 6px 0px;" name="keyword" id="keyword" /> <input type="button" id="btnSearch" name="btnSearch" value="Search" onclick="insertSearchTerm()" /> </form>
I tried this but I really have no idea what I am doing when it comes to jQuery...
<apex:includeScript value="{!$Resource.Jquery}" /> <script> $j = jQuery.noConflict(); ("#keyword").keyup(function(event){ if(event.keyCode == 13){ jQuery("#btnSearch").click(); } }); </script>
Nvm I found the solution here...
http://boards.developerforce.com/t5/Visualforce-Development/Make-a-button-click-on-pressing-enter-button/m-p/367729#M43797