spannclann has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to format the radio and submit buttons in the start_form. I would like to have them centered on the page, but I cannot find any information on how to accomplish this. Everything I have tried has failed. My code follows:

#!/usr/bin/perl -w use CGI; use CGI ":standard"; $time = localtime; $servertime = `uptime`; print header, start_html(-title=>"SysInfo", -background=>"tower.jpg", -text=>"black"), h1({-align=>center}, "Franklin University's System Information", b), start_form, radio_group( -name=>'base', -values=>['Up Time','Server Time'], -default=>'Up Time'), p, submit, end_form, hr; print CGI::center(); $base = param("base"); if ($base eq "Up Time") { printf($servertime); } else { printf($time); } print hr; print CGI::center(); $log = "count.dat"; open GETCOUNT, "<$log" or die("Error in $0: $log - $!n"); $hits = <GETCOUNT>; close(GETCOUNT); $hits++; printf "This web page has been viewed $hits times."; open COUNT, ">$log" or dienice("Cant open file to WRITE"); print COUNT $hits; close COUNT; print hr; use strict; print start_html("Browser Detect"); my($ua) = $ENV{HTTP_USER_AGENT}; if (index($ua, "MSIE") > -1) { print "The Franklin Server has determined that you are using Intern +et Explorer to access it.<p>\n"; } elsif (index($ua, "Netscape") > -1) { print "The Franklin Server has determined that you are using Netsca +pe to access it.<p>\n"; } elsif (index($ua, "Safari") > -1) { print "The Franklin Server has determined that you are using Safari + to access it.<p>\n"; } elsif (index($ua, "Opera") > -1) { print "The Franklin Server has determined that you are using Opera +to access it.<p>\n"; } elsif (index($ua, "Mozilla") > -1) { print "The Franklin Server has determined that you are probably usi +ng Mozilla to access it.<p>\n"; } else { print "The Franklin Server cannot tell what browser you are using!< +p>\n"; } print end_html;

Replies are listed 'Best First'.
Re: Centering start_form data
by InfiniteSilence (Curate) on Apr 09, 2014 at 20:42 UTC

    Centering in HTML is deprecated. You should consider adding CSS and handling the formatting of HTML elements that way.

    And while you are at it there are some interesting templating modules available on CPAN to avoid using the CGI module to generate pages altogether. Just FYI.

    Celebrate Intellectual Diversity

Re: Centering start_form data
by davido (Cardinal) on Apr 09, 2014 at 20:43 UTC

    There's nothing magical about CGI's radio group shortcut. It just outputs HTML. Discover how you would accomplish the formatting you need using plain HTML, and you'll have your answer, which is to say, it's an HTML (and possibly CSS) question.

    Often, when dealing with web page layouts, it's easier to mock up the site without any dynamic server-side stuff first... just you and the HTML/CSS. Once you've got it looking the way you want, you can replace key elements with dynamic content. Template modules make it easier too.


    Dave

Re: Centering start_form data
by Anonymous Monk on Apr 09, 2014 at 23:28 UTC
    I strongly recommend that you use templates here ... not brute-force CGI code! See Template.