Perl CGI script giving me problems
abw at wardley.org
Tue Feb 13 13:25:28 GMT 2007
peter church wrote:
> 1) make the cursor appear in the box containing the current question each
> 2) make the web page scroll down to where the box is if the page is longer
> than a standard browser window
> is this easy to achieve with the Perl CGI module?
Yes. Although as others have pointed out, this is more of an HTML
question than a Perl question.
Just in case you haven't already figured it out, this is the kind of HTML
<input type="text" name="username"/>
You need to give names to both the form and field that
you want to focus ('login' and 'username' respectively in
In this example it's embedded in the onload="" attribute of the body
tag. That's not always the best way to do it, but it'll get you going
Generating the above using the CGI module is simple. Just
specified the 'onload' and 'name' arguments to the appropriate
use CGI ':all';
-title => 'Form Focus Example',
-onload => 'document.login.username.focus()'
print start_form( -name => 'login' ),
textfield( -name => 'username' ),
When the page is displayed (assuming the user has JS available and
enabled), the cursor will automatically be focussed on the form field.
Most (if not all) browsers will scroll down to the field if necessary.
More information about the london.pm