Announcement

Collapse
No announcement yet.

Form pressing Enter not the same as clicking Save

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form pressing Enter not the same as clicking Save

    I have a form that when I click Save does what I want.... but when I type in the field and press the "enter" key the screen flashes like its doing something, but it doesn't process my code like clicking "Save".
    I have searched the forums but not found exactly what I should do.... I found a few people who use javascript code to manipulate what the "enter" key does.... but I'm not sure how to get a Form to execute javascript onload.
    The reason I need it, is for USB IR scanners that will scan a barcode and press "enter" at the end of the code in order to enter data.
    My database updates occur in an onValidateSuccess event if that makes any difference.
    Thanks!

  • #2
    you can always use jscript code by doing something like this in the onloadevent of the form

    PHP Code:
    echo "
    <script>
        
        $(function() {
            
            //Some code here
         }
           
    </script>"

    Comment


    • #3
      as kafe says - also for a bit more detail see this post:

      http://www.scriptcase.net/forum/arch...hp/t-4113.html

      Uses "Enter" as the example.

      Comment


      • #4
        Here you have to add an event listener to a edit. Use firebug to know the class of your edit.

        Try to echo something like this:

        Code:
        $(function () {
        		document.getElementById("busc0ador").addEventListener("keypress", function(e){
        			if (e.keyCode === 13) {
        				nm_alterar(); // <-- Search on forum (or use Firebug and insepct Save button) the JS function to save. I don't remember exactly
        				e.preventDefault();
        			}
        		},false);
        });
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment

        Working...
        X