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