CGI and Perl

Popup Menus

With CGI::Form, popup menus, also referred to as drop-down lists, are single selection lists that expand when the user clicks the icon to the right of the text. Unlike listboxes, popup menus can only return a single selection. Popup menus use the <SELECT> tag with SIZE equal to 1:


Using CGI::Form, a call to the method popup_menu, is shown here:

@states=( `CA', `WA', `OR', `NV', `AZ' );
 $q->popup_menu( -name=>'State', -values=>\@states, -default=>'CA' );

File-Upload Fields

File-upload fields enable the user to specify files for uploading to the server. Note that if you plan to use file-upload fields in your form, you must define your form as multipart/form-data. This is the new MIME type introduced by Netscape 2.0 for handling large amounts of data sent back to the server. This type also allows for binary data to be embedded within the form.

Using raw HTML, create file-upload fields with the INPUT tag and TYPE file:

<INPUT TYPE=file NAME=theFile>

Using CGI::Form, this is a call to the method filefield:

$q->filefield( -name=>'theFile' );