cgi.pm popup_menu define select width?

I

inetquestion

Is it possible to define the width of a select menu using cgi.pm such
as shown below?

TIA,

-Inet


<select name="myselect" class="textfield" width="130" style="width:
130px;">
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>
 
G

Gunnar Hjalmarsson

inetquestion said:
Is it possible to define the width of a select menu using cgi.pm such
as shown below?

<select name="myselect" class="textfield" width="130" style="width:
130px;">

CGI.pm seems to acknowledge an undocumented -width parameter. However,
if it ever was valid HTML to use the "width" attribute in "select"
elements, I suppose it's at least deprecated.
 
I

inetquestion

the part I'm was referring to specifically is: style="width: 130px;"

as this sets the minimum width whereas the other specifies the maximum
width.
 
B

Brian McCauley

inetquestion said:
the part I'm was referring to specifically is: style="width: 130px;"

What happened when you tried passing a style argument to popup_menu?
 
G

Gunnar Hjalmarsson

inetquestion said:
the part I'm was referring to specifically is: style="width: 130px;"

The -style parameter is described in the CGI.pm POD, and I couldn't
imagine that you asked hundreds of programmers for help to read the docs
for you.
 
A

Andras Malatinszky

Gunnar said:
CGI.pm seems to acknowledge an undocumented -width parameter. However,
if it ever was valid HTML to use the "width" attribute in "select"
elements, I suppose it's at least deprecated.

In fact CGI.pm seems to tacitly accept most any parameter, presumably in
the spirit of flexibility. For instance,

print $q->popup_menu(-name=>'myselect', -foo=>'bar');

will generate

<select name="myselect" foo="bar">
</select>

So to produce what the OP is asking for you would want to do something like

print $q->popup_menu(-name=>'myselect', -class=>'textfield',
-width=>'130', -style=>'width: 130px;');

Specifying the width via CSS is valid, but "width" as an HTML attribute
for <SELECT> is totally bogus.
 
A

Alan J. Flavell

In fact CGI.pm seems to tacitly accept most any parameter,
presumably in the spirit of flexibility. For instance,

print $q->popup_menu(-name=>'myselect', -foo=>'bar');

will generate

<select name="myselect" foo="bar">

Indeed; and this is CGI.pm's trick for supporting attributes which
aren't explicitly known. But it means that acceptance by CGI.pm is
absolutely no guarantee of meaningfulness as far as HTML is concerned
(which I'm sure was the point you were intending to make here)
Specifying the width via CSS is valid, but "width" as an HTML
attribute for <SELECT> is totally bogus.

Completely OT for Perl, but google suggests
http://www.blooberry.com/indexdot/html/topics/selectwidth.htm
which looks quite a sensible analysis of the issue, it its way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,765
Messages
2,569,568
Members
45,042
Latest member
icassiem

Latest Threads

Top