himanshu.padmanabhi has asked for the wisdom of the Perl Monks concerning the following question:

I have a code in CGI where i want to print "yes/no + button " together in a single line, i.e.

Yes Disable

No Enable

but i am getting them in 2 separate lines like

Yes

Disable

No

Enable

The statement is as follows :
push (@row_list,$st->{'enabled'} ? "$text{'yes'} <form name=f1 action= +\"file1_on.cgi?idx=$d->{'device'}\" method=post > <input type =Submit + value=Disable width=10% ></form>": $text{'no'} . "&nbsp <form name=f +2 action=\"file2_off.cgi?idx=$d->{'device'}\" method=post > <input ty +pe =Submit value=Enable ></form>");
Can anyone guide me how to achieve the above ?

Replies are listed 'Best First'.
Re: yes/no + button together in a single line
by dreadpiratepeter (Priest) on May 05, 2009 at 15:06 UTC
    This is actually a HTML question, but anyway. the problem is that you have each of your buttons in a separate form, which (besides being poor design) is causing your problem. I believe form tags are considered to be block level elements.
    You can try several things:
  • 1 - put style="display: inline;" into your form tags
  • 2 - fix your cgi to have 1 handler that uses the value submitted for the button to determine how to behave


    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
Re: yes/no + button together in a single line
by Your Mother (Archbishop) on May 05, 2009 at 16:46 UTC

    (update: changed phrasing) You should probably be using CGI.pm for this. Here's a starting snippet.

    use strict; use warnings; use CGI qw(:standard); my %enable = ( yes => "Yes", no => "No", ); print header(), start_html(), start_form(-method => "post"), radio_group(-labels => \%enable, -name => "enable", -value => [ values %enable ]), end_form(), end_html();