use warnings; use strict; use CGI::Pretty qw(:standard); # plain CGI will do too #========================================== my %id_to_term = ( 92 => 'Tuna', 3 => 'Ceolocanth', 4 => 'Ratfish', 7 => 'Six Gill Shark', 13 => 'Albino Pygmy Sperm Whale', ); print header(), start_html(), start_form(); print h3("Regular"), popup_menu( -labels => \%id_to_term, -values => [ sort keys %id_to_term ], ); print h3("Shortened"), popup_menu( -style => "font-size:75%;", -labels => \%id_to_term, -values => [ sort keys %id_to_term ], ); print h3("Moreso"), popup_menu( -style => "font-size:60%;", -labels => \%id_to_term, -values => [ sort keys %id_to_term ], ); # now we modify the values with word_chop since we're able to look up # by the IDs anyway, it doesn't matter that we modify them my %id_to_chopped_term = %id_to_term; while ( my ( $id, $term ) = each %id_to_chopped_term ) { $id_to_chopped_term{$id} = word_chop($term, 12); } print h3("Okay, that's ridiculous"), popup_menu( -style => "font-size:50%;", -labels => \%id_to_chopped_term, -values => [ sort keys %id_to_chopped_term ], ); print end_form(), end_html(); exit 0; #=========================================== sub word_chop { my ( $text, $chars ) = @_; $chars ||= 15; return $text if $chars >= length $text; return substr($text, 0, $chars) . '...'; }

In reply to they've all got CSS in them but the last example doesn't need it by Your Mother
in thread CGI form element sizing issue by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.