in reply to perl cgi standalone checkbox label problem

So close-

       -labelattributes => { id => 'checkboxlabel_id' }

The instructions, CGI, with it say you need an associative array ref (hash ref), not an array ref. Just update as shown.

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

      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?