in reply to Re: perl cgi standalone checkbox label problem
in thread perl cgi standalone checkbox label problem

Wow, that was a fast answer... Thanks! But unfortunately I got bad news for you. I already tried this too. Resulting code:
<label><input type="checkbox" name="my_checkbox" value="on" labelattri +butes="HASH(0x9c9a888)" />label of my checkbox. Check Me!!!</label>
So all that changed was that instead of Array(RefToArray), I got Hash(RefToHash) in my HTML output...

Replies are listed 'Best First'.
Re^3: perl cgi standalone checkbox label problem
by Your Mother (Archbishop) on Apr 06, 2009 at 21:35 UTC

    Er... Then you didn't try it right.

    use CGI; print CGI::checkbox(-name => 'my_checkbox', -checked => 0, -value => 'on', -label => 'label of my checkbox. Check Me!!!', -labelattributes => { id => 'checkboxlabel_id' } ); __END__ <label id="checkboxlabel_id"><input type="checkbox" name="my_checkbox" + value="on" />label of my checkbox. Check Me!!!</label>

      You're joking, right? I mean, this can't be serious that I'm trying the stuff you do and everything works for you but not for me... The complete code within my script:
      #!/usr/bin/perl use CGI qw/:standard/; print CGI::header; print CGI::start_html; print CGI::checkbox(-name => 'my_checkbox', -checked => 0, -value => 'on', -label => 'label of my checkbox. Check Me!!!', -labelattributes => { id => 'checkboxlabel_id' } ); print CGI::end_html;
      The complete output I get:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <label><input type="checkbox" name="my_checkbox" value="on" labelattri +butes="HASH(0x825cd28)" />label of my checkbox. Check Me!!!</label> </body> </html>
      Could this be any problem of my machine or whatsoever? I mean, I just copied and pasted your code! Or have I put in any error again?

        Nice! No, your code works fine for me. Try this:

        perl -MCGI -le 'print CGI->VERSION' 3.40

        If your CGI version is much behind that, give upgrading a shot.

        I too get no label attribute when I run your code, until I update CGI with current version from CPAN, after which the attribute is added.