in reply to Re: Creating HREF links on radio group items
in thread Creating HREF links on radio group items

You'll need to undef autoEscape if you want this to work here, otherwise the labels will be the actual HTML generated by the a() method.

autoEscape(undef); print radio_group (-name => "item", -value => ["B","T","S","M"], -labels => { 'B' => 'Item '.a({-href=>"/help/b.html"},"B").' + ($10)', 'T' => 'Item .a({-href=>"/help/b.html"},"T").' +($50)', 'S' => 'Item .a({-href=>"/help/b.html"},"S").' +($200)', 'M' => 'Item .a({-href=>"/help/b.html"},"M").' +($500)' }, -linebreak => 1); autoEscape(1);
You'll also need to import the autoEscape method, by adding
use CGI qw/:standard autoEscape/;

Maybe there's a more elegant way to do this? Anyone?

Update: Fixed syntax errors I cut-and-copied. . .

-Any sufficiently advanced technology is
indistinguishable from doubletalk.

Replies are listed 'Best First'.
Re: Re: Re: Creating HREF links on radio group items
by little (Curate) on Jun 21, 2002 at 19:04 UTC
    Well, ok, I didn't think so far for now :-)
    Ok and the URL's also should be the ones for the documents then and not a unique one, ok.
    But in CGI.pm's POD there seems to be no such Pragma -autoEscape, but that might be due to the fact that I read the docs on my PC where not the newest AS Perl and hence not the newest CGI.pm is installed. The docs rather say "By default, all HTML that is emitted by the form-generating functions is passed through a function called escapeHTML() ..." and "... To turn autoescaping off completely, use autoescape() ..." along with samples.

    Have a nice day
    All decision is left to your taste
Re: Re: Re: Creating HREF links on radio group items
by Anonymous Monk on Jun 21, 2002 at 19:53 UTC
    I simplified an item line,

    "B" => a({href=>"/test.html";},"B"),

    but I get the error:

    syntax error at /usr/local/apache/cgi-perl/work/script.pl line 95, at EOF

    Line 95 is the line I give above.

    Any idea why I'm getting this error?

      That's because your call to a() is wrong, it should be:

      a({-href=>"/test.html"},"B")
      Note the addition of the the - and the removal of the ;
      Goes to show what happens when I just cut-and-paste code, without really reading it. . .

      -Any sufficiently advanced technology is
      indistinguishable from doubletalk.

        Thanks. The dash is optional I guess since it appears to work without it. I`ll try both ways.
      got it. the semicolon should not be there.