Signal.connect($CF, "postInit", {c: function() {
var cardScan = false;
var ccNumber = $('searchCriteria.creditCardNumber');
var ticketBarcode = $('searchCriteria.ticketBarCode');
function listenForScan(event) {
this.controlKey = event.ctrlKey;
if (this.controlKey && event.keyCode == 220) {
ccNumber.focus();
cardScan = true;
this.controlKey = false;
} else if (!cardScan && event.keyCode == 48) {
ticketBarcode.focus();
}
}
Event.observe(document, "keydown",
listenForScan.bindAsEventListener(document));
Event.observe(ccNumber, "change",
formSubmit.bindAsEventListener(ccNumber));
Event.observe(ticketBarcode, "change",
formSubmit.bindAsEventListener(ticketBarcode));
function fillCardInfoFromScan(scanInfo) {
var segments = scanInfo.match(/;(\d+)=(\d{2})(\d{2})/);
if (segments == null || segments.length < 2){
alert("Invalid Scan");
} else {
ccNumber.value = segments[1];
}
function formSubmit() {
if (cardScan) {
fillCardInfoFromScan(ccNumber.value);
cardScan = false;
}
document.<portlet:namespace/>form.submit();
}
}}, "c", {before:true});
I have two text fields on my page and i am listening for scans. If its
a card scan, i am grabbing the scan value, fitering the card number
from scanned value, filling the cardnumber text field and submitting
the form. If its an barcode scan i am filling the barcode text field
and submitting the form.
So i have eventListener (for keydown) on my document which will bring
the respective field in focus depending on the scan (card or barcode)
and i have eventListeners (for change) on my text fields which will
submit the form on value change.
The above code works fine on firefox but in IE6 once i scan i have to
click anywhere on the page to trigger onChange event for the text
field.
Is there any way to implement this on IE6 ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---