Glideh / jquery-code-scanner

Lightweight handheld code scanner detector
31 stars 16 forks source link

Multiple textbox #3

Open kcviper opened 7 years ago

kcviper commented 7 years ago

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

Glideh commented 7 years ago

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).

LuisRodriguezLD commented 5 years ago

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

Any work around?

Glideh commented 5 years ago

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

LuisRodriguezLD commented 5 years ago

exactly! I am currently trying to make it work

Glideh commented 5 years ago

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

LuisRodriguezLD commented 5 years ago

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

Glideh commented 5 years ago

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

LuisRodriguezLD commented 5 years ago

managed to do something similar, thank you very much!