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

Using CGI how do you put 2 $q-> inside of a table cell.
e.g. $q->td( $q->submit (-value=>'Submit') $q->reset )

$q->td( $q->submit (-value=>'Submit'), $q->reset )
The comma puts it in its own cell.

Thanks ahead of time!

Replies are listed 'Best First'.
Re: CGI question
by davido (Cardinal) on Apr 17, 2004 at 15:20 UTC
    Untested, but perhaps instead of a comma you can concatenate:

    $q->td( $q->submit( -value=>'Submit') . $q->reset );

    In the bigger picture, you may want to read the cgi.pm reset button question thread, for a discussion on why you probably shouldn't even bother to use a reset button in your script. It seems to be good advice.


    Dave

      That did the trick. Thanks you!!
        The thing to remember (and why concatenation worked) is that CGI scripts basically just output text. The text happens to be HTML text. And the CGI.pm "HTML shortcuts" are the functions that create the text. Since the HTML shortcuts' return values are all just strings, concatenation is an option in cases where you want two entities combined, and a comma would signify two separate items (such as in the case of lists or tables).

        You kind of have to know how a given HTML shortcut looks in its text return-value form. For that, it's convenient to run the CGI script from the command line so you can see what output you're getting and why (or why not) it's doing what it's doing.


        Dave

Re: CGI question
by blue_cowdawg (Monsignor) on Apr 17, 2004 at 20:34 UTC

        Using CGI how do you put 2 $q-> inside of a table cell.

    what's wrong with:

    print $q->td($q->submit(-value=>'Submit'),$q->reset);
    When I ran that code I got:
    <td><input type="submit" name=".submit" value="Submit" /> <input type= +"reset" /></td>

    looks correct to me...

      The comma was putting it into its own <td>.

            The comma was putting it into its own <td>

        Hrmmm... I cut/pasted your code and it worked for me...