This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Integration with barcode scanner

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Integration with barcode scanner

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #50188
    samuelepellizzarisamuelepellizzari
    Participant

    Hi there,

    I’m trying to integrate your plugin with a barcode scanner using the phone camera.

    The scanner works well in that it scans and places the right value in the Ajax Search Pro form, with the following Javascript code upon scanning:

    $(“input.orig”).val(sBarcode);

    However, the search isn’t triggered, unless I click on the form and press enter.

    Could you please advise?

    Many thanks,

    Samuele Pellizzari

    #50195
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Sure! You can use the search javascript API to trigger the search, even to input the value you need:

    ASP.api(1, "searchFor", sBarcode);

    #50196
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Many thanks for your reply!

    Would that trigger the ajax live search, too? That would be nice, in order not to leave the page.
    Or triggering live results would require a different code?

    Thanks again,

    Samuele

    #50199
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are welcome! Yes – this triggers the live search as well.

    #50203
    samuelepellizzarisamuelepellizzari
    Participant

    Hi Ernest,

    Sorry, but I can’t get it to work. Probably am I missing something? Here is the complete code:

    var barDataEl = document.getElementById('status');
    for (var i = 0; i < barcodeResult.length; ++i) {
    	var sBarcode = DSScanner.bin2String(barcodeResult.at(i));
    	barDataEl.innerHTML = barcodeResult.at(i).type + ': ' + sBarcode;
    
    $("input.orig").val(sBarcode).focus();
    
    ASP.api(1, "searchFor", sBarcode);
    
    }
    #50204
    Ernest MarcinkoErnest Marcinko
    Keymaster

    The search ID might be incorrect, maybe dynamically fetching it could work:

    ASP.api(parseInt($('input.orig').closest('.asp_w').data('id')), "searchFor", sBarcode);

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.