Using barcode reader, CGI form, <iframe> to display a PDF document

J

Jimbo

I have a simple CGI script that uses this form:

print start_form(-name=>'f'),
table(
TR(
td("Number: "),
td(textfield (-name=>"param1", -value=>"")),
td(),
td(submit (-name=>"action", -value =>"Submit")),
td(submit (-name=>"action", -value =>"Clear")),
),
),

endform,
;

The HTML output resembles this:

Number: [ ] [Submit] [Clear]

The textfield is given focus by doing these two things:

1.
print header,
start_html(-script=>$JSCRIPT,
-onLoad=>'on_load()',
-onUnload=>'on_unload()',
),
;

2.
my $JSCRIPT=<<EOF;
function on_load() {
document.f.param1.focus();
document.f.param1.select();
}

function on_unload() {
document.f.param1.focus();
document.f.param1.select();
}

The user-supplied textfield input (the "number") comes from a barcode
reader--there is no keyboard and no mouse. The first time the program
is run and a barcode is scanned, a PDF file gets displayed via the
<iframe> tag:

my $param1 = param('param1');
if (exists $portfolio{$param1})
{
print "<iframe onChange=\"on_change()\"
src=\"/portfolio/${param1}.pdf\" width=100% height=800></iframe>";
} else {
print "No matches were found.";
}

So far, so good. Now here's where things go wrong: when subsequent
numbers are scanned with the barcode reader, all that happens is: the
PDF file goes to the next page (or stops at the last page).

After the first read, the number in the textbox is in fact selected,
but the \r of the reader is affecting the Adobe Acrobat reader in the
<iframe>, i.e., the new number and \r aren't replacing the previous
number in the textfield.

I've tried doing these to no avail: onBlur, onChange, onSubmit, etc.

I've even tried appending this to the end of the barcode reader output:
\r\t\t\t\t\t\t\t to get focus back where it should be (on the
textfield) but that had inconsistent results (first time vs. subsequent
times).

TIA

Jim
 
J

Jimbo

Clarification: the desired behavior is: each time a barcode is scanned,
a new PDF document gets displayed, all without any interaction from a
keyboard or mouse.

Background: This program is being used for a presentation; I'll be
using a wireless barcode reader from about 10-to-30 feet away from the
PC (which in turn is quite a distance away from the server ;-) ). The
PC is connected to an overhead projector.
 
J

Jimbo

Well, it took a few hours of trial and error. I ended up replacing
<iframe> with <embed> and got the desired behavior. All that for that.
Sigh. It's the journey that matters, right? Heh heh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top