jquery-code-scanner icon indicating copy to clipboard operation
jquery-code-scanner copied to clipboard

Multiple textbox

Open kcviper opened this issue 8 years ago • 8 comments

I'm having issues with multiple textboxes to execute different scripts. Because right now when selecting one textbox, it's executing all textboxes scripts.

kcviper avatar Jul 20 '17 12:07 kcviper

Well if you focus your inputs before scanning you don't need this plugin. The input will be filled as if you typed with the keyboard. The aim of this plugin is to catch a scanned code without any previous user action (ie selecting an input).

Glideh avatar Jul 20 '17 14:07 Glideh

I am with kcviper on this one, what if the user scans multiple codes in the same form.

Any work around?

LuisRodriguezLD avatar Feb 18 '19 18:02 LuisRodriguezLD

You mean each time he scans, the code should go in the next input ?

Glideh avatar Feb 18 '19 18:02 Glideh

exactly! I am currently trying to make it work

LuisRodriguezLD avatar Feb 18 '19 18:02 LuisRodriguezLD

You could set the plugin in one input and implement the onScan so it fills the next empty input

Glideh avatar Feb 18 '19 18:02 Glideh

yes that works great but what if I have multiple barcodes to scan on different inputs. the onScan fires for all of them at the same time

LuisRodriguezLD avatar Feb 18 '19 18:02 LuisRodriguezLD

No you put the plugin only on one input responsible for all the others. The input on which the plugin is set is not important (you can even put it in the form) The important thing is your implementation of onScan

Example:

<form id="your_form">
  <input type="text" class="scanable">
  <input type="text" class="scanable">
  <input type="text" class="scanable">
  <input type="text" class="scanable">
</form>
$('#your_form').codeScanner({
    onScan: function ($element, code) {
        $element.find('input.scanable[value=""]').first().val(code);
    }
});

Not tested but should work

Glideh avatar Feb 18 '19 18:02 Glideh

managed to do something similar, thank you very much!

LuisRodriguezLD avatar Feb 18 '19 21:02 LuisRodriguezLD