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

Hi, i have 2 scroll_list and moving items between them. Initially one list will be empty and want set the width of the list fixed.
scrolling_list({-name=>'constraints',-size=>'12',-width=>'15',-value=> +'',-multiple=>'true'})
What i want is fixed width empty list. But when the value is empty width is reduced to 1. please help me out.

Replies are listed 'Best First'.
Re: setting fixed width for scroll_list
by davorg (Chancellor) on Oct 11, 2006 at 12:53 UTC

    You need to tell us what technology you are talking about. The name of the function you're calling is the same as a function in CGI.pm, so I'd guess that you're using CGI.pm to create HTML - but that's not obvious. There could be any number of other technologies that have a similarly named function to create similar widgets.

    But assuming that you are talking about CGI.pm and HTML, you need to look at the HTML that's generated. It sounds to me as tho' the width of a list with no items should still be controlled by the width attribute - but that decision will be made by the browser. Are you still generating a valid width attribute when the list is empty?

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: setting fixed width for scroll_list
by Melly (Chaplain) on Oct 11, 2006 at 13:26 UTC

    There is no width option for this form element. This is a limitation of HTML forms, not perl.

    A select should have at least one option according to w3.org.

    Basically, you're out of luck...

    .
    Tom Melly, tom@tomandlu.co.uk
Re: setting fixed width for scroll_list
by fenLisesi (Priest) on Oct 11, 2006 at 14:28 UTC
    This is not a perl issue, but a quick search reveals some CSS might help, as in the following:
    my $q = CGI->new(); print $q->header(), $q->start_html('Fixing the width of a <select> widget'), $q->h1('Fixing the width of a &lt;select> widget'), $q->start_form, $q->scrolling_list( -name =>'constraints1', -width => 300, -style => 'width:300px', -size => 12, -multiple => 300, -values => [], ), $q->p(), $q->scrolling_list( -name =>'constraints2', -width => 300, -style => 'width:300px', -size => 12, -multiple => 300, -values => [1..20], ), $q->end_form(), $q->hr(), ;