5 Replies Latest reply on May 24, 2006 9:15 AM by drforbin1970

    Interesting form input

    ShapeShift
      Goodday all. Let me give you a brief overview of what im trying to do.
      I am developing a a stock management system. And for that we need to take stock.
      We use barcodes, which is not a problem.

      But however i do not want to have to press a button after each barcode i enter. via barcode scanner.
      Therefore i have already developed the java function that does what i need it to do. the problem is the actual input

      Calling the function using onchange does not work as we need to press a button .
      on keypress does not work as the codes are more than one char.

      So my question is, is there any way of delaying the java call for all the chataceters to be placed into the input fied.

      Any help would be appreciated.

      Regards
      Donovan
        • 1. Re: Interesting form input
          drforbin1970 Level 1
          Hard to comment without code sample but perhaps a SetTimeOut call in JavaScript or have a JS routine to continuously check the size of the input field until it reaches the desired/maximum length, then submit.
          • 2. Re: Interesting form input
            ShapeShift Level 1
            i dont know the maximum length, that is the problem, it differs everytime, i just need an onchange or on key pressed event that works with a time delay so the whole barcode can be scanned.
            • 3. Re: Interesting form input
              crmcw
              Can you send an <Enter> key stroke in you barcode scanner after it scans the data? If so, and if your form uses a submit, you can tab off the entry field and onto the button where you "press" the space bar or enter key via scanner programming.
              • 4. Re: Interesting form input
                drforbin1970 Level 1
                I agree with comment stating have barcode software sending an ending input character. But if you cannot enable that, write a JavaScript routine that fires when the field receives input. Have the routine continously check the field for, say, length of value in field. When the length stays constant for more than 3 seconds, then the barcode has been fully inputted and submit the form.

                Just a thought.
                • 5. Re: Interesting form input
                  drforbin1970 Level 1
                  Here's one way to do it. The JavaScript routine fires when the value in the input text box changes. Routine takes a snapshot of the length of the value in the input box and initializes a setTimeout for three seconds. After three seconds, the setTimeout compares the snapshot with the current length value. If snapshot=current value, user input has ceased and form is submitted. You can raise the setTimeout time value or lower it based on input speed of barcode equipment, etc.

                  <script language="JavaScript">

                  var i = ""; //set global variable for setTimeout call

                  function bar_init(bar_snapshot_len){
                  if(i){clearTimeout(i);} //clear previous setTimeout if defined
                  i = setTimeout(function(){bar_check(bar_snapshot_len)}, 3000); //raise or lower time based on input speed
                  }

                  function bar_check(bar_prev_value){
                  if(bar_prev_value==document.myform.x.value.length){
                  window.document.myform.submit();
                  }
                  }
                  </script>

                  <form name="myform">
                  <input type="text" name="x" onpropertychange="bar_init(document.myform.x.value.length)" size="50">
                  </form>