asked on August 22, 2024
•
Show version history
Hello all. I have a form using the script below. The Label Part Scan field is meant to accept value from a scanner. What I am struggling to get working is to set the Focus to the Job# field in the same row as the Label Part Scan field that just changed.
I was able to get it working outside a Collection, but inside the collection, the cursor stays at the Label part Scan field after the scaned value and does NOT move to the Job# field.
$(document).ready(function() { // debugger; $('li[attr="Collection"]').on("change", 'li[attr="Scan"] input', compare2Table); }); function compare2Table() { let barcode = this.value; let el_row = $(this).closest('ul'); let el_part = $(el_row).find('li[attr="Part"] input'); let el_posative = $(el_row).find('li.posative'); let el_negative = $(el_row).find('li.negative'); let el_matched = $(el_row).find('li[attr="Matched"] input'); // Find the matched field if (el_part.length > 0) { if (barcode && barcode === el_part[0].value) { console.log('Match'); // $(el_posative).removeClass('hidden'); // $(el_negative).addClass('hidden'); $(el_row).css('background-color', '#AFE1AF'); $(el_matched).val(1); } else if (barcode && barcode != el_part[0].value) { console.log('No match'); // $(el_posative).addClass('hidden'); // $(el_negative).removeClass('hidden'); $(el_row).css('background-color', 'red'); $(el_matched).val(0); } else { console.log('barcode is empty'); // $(el_posative).addClass('hidden'); // $(el_negative).addClass('hidden'); $(el_row).css('background-color', ''); $(el_matched).val(0); } } };
0
0