sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:

I usually ask such a small question in the CB but people are ignoring me (probably asking too many questions and finally annoying some monks, lol). My table below works fine before I add the form field but now the table doesn't show up. No errors are printed but the table disappears. How can I get my form to print inside of tables like this?

print table( Tr( th( 'Column' ), th( 'Headings' ), ), Tr( td( $query->textfield('keywords') ), td( 'top right' ), ), Tr( td( 'bottom left' ), td( 'bottom right' ), ) );
Thanks.

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re: Tabular monstrosities
by VSarkiss (Monsignor) on Mar 31, 2003 at 18:15 UTC

    Where are you putting the opening and closing of the form? That could well be the cause of the problem. Also, I can't tell if you're using OO style or "standard" style CGI, since you're using shortcuts, but also $query->textfield().

    Here's an example that should work, presuming you're not using any other fields in the same form, and that you're using shortcuts consistently (that is, that you have use CGI qw(:standard):

    print start_form(), table( Tr( th( 'Column' ), th( 'Headings' ), ), Tr( td( textfield('keywords') ), td( 'top right' ), ), Tr( td( 'bottom left' ), td( 'bottom right' ), ), end_form();
    Warning, this is untested.

Re: Tabular monstrosities
by dragonchild (Archbishop) on Mar 31, 2003 at 18:26 UTC
    Better would be to use the OO interface, as it simplifies things immensely. I would suggest rewriting to that interface and 99% chance the problem will resolve itself. (Rewrites usually resolve niggles, in my experience.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      I would disagree about using the OO form for the html subs. It's gets ugly quick. Though you would need it for form inputs if you have multiple objects (That or local $CGI::Q = $cgi; before the form fields)

      -Lee

      "To be civilized is to deny one's nature."
      Update
      To be honest, I'm suprised this was down-voted. I'm curious what the arguments for this
      print header(), table ({-border=> "0", -width=> "340"}, Tr ({-valign=> "top"}, td ( font ({-face=> "verdana,arial"}, " Column One ", ), "\n", ), "\n", td ( font ({-face=> "verdana,arial"}, " Column Two ", ), "\n", ), "\n", ), "\n", Tr ({-valign=> "top"}, td ( font ({-face=> "verdana,arial"}, " Data ", ), "\n", ), "\n", td ( font ({-face=> "verdana,arial"}, " Data ", ), "\n", ), "\n", ), "\n", ), "\n", ;
      verse this are
      print $cgi->header(), $cgi->table ({-border=> "0", -width=> "340"}, $cgi->Tr ({-valign=> "top"}, $cgi->td ( $cgi->font ({-face=> "verdana,arial"}, " Column One ", ), "\n", ), "\n", $cgi->td ( $cgi->font ({-face=> "verdana,arial"}, " Column Two ", ), "\n", ), "\n", ), "\n", $cgi->Tr ({-valign=> "top"}, $cgi->td ( $cgi->font ({-face=> "verdana,arial"}, " Data ", ), "\n", ), "\n", $cgi->td ( $cgi->font ({-face=> "verdana,arial"}, " Data ", ), "\n", ), "\n", ), "\n", ), "\n", ;
      They are both functionally equivalent for non-form fields, only the first is more shorter and clearer to read. Unless you are subclassing CGI.pm and have special instance specific stuff tied to the HTML generation of non-form fields, why would you use the latter?
Re: Tabular monstrosities
by shotgunefx (Parson) on Apr 01, 2003 at 14:44 UTC
    You might want to check out merlyn's html 2 CGI parser column. It doesn't handle checkbox_group's ( I do have a version that does handle this somewhere, if it's helpful I'll look for it and post it) but it helps a lot with complex HTML if you are using CGI.pm to generate.

    -Lee

    "To be civilized is to deny one's nature."