Nath, Alok (STSD) wrote:

: I am generating a simple form which generates different
: textfields and scrolling list in different rows. When I display
: the form what I see is, the different textfields and scrolling
: list are not aligned vertically. I want the textfields and
: scrolling list to start under a particular column.

    Like Rob, I suggest a table, but I like to fashion my sub
routines the same way CGI.pm does by returning text values.

print my_form();

sub my_form {
    my $cgi = CGI->new();

    return
        $cgi->startform( -method => 'GET' ),

            $cgi->start_table(),

                form_row(
                    'Field A',
                    $cgi->scrolling_list(
                        -name    =>  'field',
                        -default => ['field_1'],
                        -values  => [
                            'field_1',
                            'field_2',
                            'field_3',
                            'field_4',
                        ],
                    ),
                ),

                form_row(
                    'Field B',
                    $cgi->textfield( -name => 'field_b' ),
                ),

                form_row(
                    'Field C',
                    $cgi->textfield( -name => 'field_c' ),
                ),

                form_row(
                    'Field D',
                    $cgi->textfield( -name => 'field_d' ),
                ),

            $cgi->end_table,

        $cgi->endform();
}

sub form_row {
    my( $field, $control ) = @_;

    my $cgi = CGI->new();

    # adjust column widths to taste.
    return
        $cgi->Tr(
            $cgi->td( { -width => '30%', -valign => 'top' }, $field,   ),
            $cgi->td( { -width => '70%', -valign => 'top' }, $control, ),
        );
}

__END__



HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to