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

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>

Replies are listed 'Best First'.
Re^4: perl cgi standalone checkbox label problem
by Anonymous Monk on Apr 06, 2009 at 21:50 UTC
    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.

        Thanks man, that did it. Didn't know that the versions changed so rapidly. I just installed CGI through CPAN about one week ago and by running your command I got 3.29 for the version installed. Did an update to the newest version (3.43) and look what happens, it works... Thanks again for your help and patience... :)

      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.