Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Formatting labels of checkbox groups

by Zed_Lopez (Chaplain)
on Aug 16, 2004 at 05:02 UTC ( [id://383196]=note: print w/replies, xml ) Need Help??


in reply to Formatting labels of checkbox groups

From an old version of the docs, and still applicable in CGI.pm 3.04:
This function actually returns an array of button elements. You can capture the array and do interesting things with it, such as incorporating it into your own tables or lists. The -nolabels option is also useful in this regard:
@h=$query->checkbox_group(-name=>'choice',-value=>['fee','fie','foe'], + -nolabels=>1); create_nice_table(@h);
Or generate them one at a time in a loop with
CGI::checkbox(-name => 'the_group', -value => $value, -label =>'')
, giving them all the same name, and CGI.pm can process it just like it was made with checkbox_group.

Replies are listed 'Best First'.
Re^2: Formatting labels of checkbox groups
by lcanty (Friar) on Aug 16, 2004 at 05:45 UTC
    Hey Zed,

    I've tried to generate the checkboxes one at a time like in your second example.

    CGI::checkbox(-name => 'the_group', -value => $value, -label =>'')

    Now what i require is something similar to...

    $some_spaces = " " #here are 4 spaces. $my_label = $title . $some_spaces . $description . $somespaces . $more +text # the variables above just represent some basic information CGI::checkbox(-name => 'the_group', -value => $value, -label =>$my_lab +el)
    now what i'd expect from the web page is a checkbox with a label that has each part split by 4 spaces.
    Unfortunately the html is being smart and removing unnecessary white space, so what i end up with is each variable only being seperated by a single space, ideally what im looking for is a way to get around this.
    any more ideas would be appreciated

    thanks

      Sorry, I thought the crux of the matter was doing complex, dynamic labelling that was inconvenient with checkbox_group.

      Like the first respondent said, you could use ' ' x 4 instead of 4 spaces. If what you really want is columns, use HTML tables or CSS.

      Or use -label => '' and put in your own label after the checkbox by hand with CGI::pre("$title    $description    $moretext")

        Hey again Zed,

        well actually the problem started with dynamic labelling of anywhere between 10 - 2000 checkboxes, which obviously meant creating the one checkbox_group. Unfortunately though im building a web-based interface to some webmin modules. (Webmin is a web base interface to Unix/Linux written in perl)
        http://www.webmin.com/intro.html
        because of this CSS is out of the question.
        Currently the checkbox structure is already in it's own table with columns, but that's where i keep running into blocks. i also require the checkbox labels to also be in columns.
        I was hoping to also achieve this without having to create the possible 2000 boxes individually on the fly.

        i've already tried    but that didnt work, instead all it does is interpret the &nbsp and print it with part of the label.
        I've also tried

        CGI::pre("$title $description $moretext")
        but that seems to embed the  <PRE>tags into the actual desription rather than interpreting them as the html that they're meant to be.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://383196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (1)
As of 2024-04-19 18:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found