Bill Stephenson <mailto:[EMAIL PROTECTED]> wrote:
: I'm trying to format the text used in my labels for a radio box group
: created with CGI.pm... Among other things, I've tried:
: 

    I'm guessing that you have something like this somewhere.

use CGI qw/:standard/;
my $Q = CGI->new();

    It is not good idea to mix the function and object oriented calls
to CGI.pm.


:       my $payPal_label= b(Pay Online with PayPal)," (Use this for instant
: access)";

    You should consider enabling strict and warnings. There are a few
problems up there.

my $payPal_label = $Q->b( 'Pay Online with PayPal.' ) .
                       ' (Use this for instant access)';


:       my $check_label=qq~ <b>Send a Check in the Mail.</b> (If you're
: having a difficult time making a payment with PayPal use this option
: instead.)~;
: 
:       my %payment_labels = ('PayPal'=>"$payPal_label",
:                                  'Check' =>"$check_label");

    Do not quote variables. ( Perlfaq4 ).

my %payment_labels = (
    PayPal  => $payPal_label,
    Check   => $check_label
);



:       my $payment_type=$Q->radio_group(-name=>'payment_type',
:                                                        -values=>['PayPal',
'Check'],
:                                                        -default=>'PayPal',
:                                                        -linebreak=>1,
:
-labels=>\%payment_labels);
: 
: ######### end code
: 
: The "Bold" text doesn't work on either of the labels. As I said, I've
: tried to do this in a variety of ways, but I keep getting an error or
: the browser displays the "<b>" tags because CGI.pm converts it to
: this, "&lt;b&gt;".

     In the CGI.pm docs, read the section on AUTOESCAPING HTML.

$Q->autoEscape(0);

my @payment_type = $Q->radio_group(
                        -name       => 'payment_type',
                        -values     => ['PayPal', 'Check'],
                        -default    => 'PayPal',
                        -linebreak  => 1,
                        -labels     => \%payment_labels
);

$Q->autoEscape(1);

    Or (better):

my @payment_type;
{
    my $flag = $Q->autoEscape(0);

    @payment_type = $Q->radio_group(
                        -name       => 'payment_type',
                        -values     => ['PayPal', 'Check'],
                        -default    => 'PayPal',
                        -linebreak  => 1,
                        -labels     => \%payment_labels
    );

    $Q->autoEscape( $flag );
}





HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to