How do you padd textboxes in cgi. I have 2 colums of textboxes but would like to more spacing in column and rows.

print $q->Tr(
  $q->td('Semester:'),
  $q->td(
  $q->checkbox_group(
    -name => 'semester',
    -values => ['Spring 2012', 'Summer 2012', 'Fall 2013 ', 'Spring 2013', 'Summer 2013', 'Fall 2013', 'Spring 2014', 'Summer 2014'],
    -defaults => ['Spring 2012'],
    -columns => 2,
    )
  )
);

Hi,
What you have are checkboxes, which are table data of a table row. So changing the both table attributes and the row attributes could help.
See a modification of your code below, and please tell us know if it works.

use warnings;
use strict;
use CGI qw(:standard);

my $q = new CGI;

print $q->start_html( -title => 'Home Page' ),
  $q->table(
    { -border => '3', -cellpadding => '20', -width => '65%', },
    Tr(
        td('Semester:'),
        td(
            { -align => 'center' },
            checkbox_group(
                -name   => 'semester',
                -values => [
                    'Spring 2012',
                    'Summer 2012',
                    'Fall 2013 ',
                    'Spring 2013',
                    'Summer 2013',
                    'Fall 2013',
                    'Spring 2014',
                    'Summer 2014'
                ],
                -defaults => ['Spring 2012'],
                -columns  => 2,
            )
        )
    )
  );
print $q->end_html;

and please tell us know if it works

I tried your script, and it displayed the boxes with the wrong padding
Here what I did ...
Changed the center align to left and the "right" boxes to left align and it worked
I also changed the % from 65 to 33

Hi arishy,

I tried your script, and it displayed the boxes with the wrong padding

It worked well for me. Moreover, the script was to serve as a guide, which should be used or modify to the users taste.
Also note that the value of cellpadding or cellspacing can either be in pixels or percentage. So, with the % is in pixels.

Hi 2teez,
I thought you did not try it yourself, and since I liked your script; I thought I give it a try and answer "if it works?". I am ready to show you some screen shots from my trial(s) in order to refine it for whoever is interested. If you are interested I can detail what I did and pin point the difference...If you have the time that is!!!!
I appreciate putting your time and sharing your experience.

Hi arishy,

I am ready to show you some screen shots from my trial(s) in order to refine it for whoever is interested. If you are interested I can detail what I did and pin point the difference...If you have the time that is!!!!

By all means please. I will like to see those. For the time? I will make up the time.

Again, Please let my correct my pervious statement.

So, with the % is in pixels.

That should be "So, WITHOUT [ NOT WITH ] the % is in pixels".

I will be waiting to see, those screen-shots.
Thanks for your time.

Here we go, I will make it short but complete. As you will see the output of your generated HTML is the first screen shot followed by the changes I made in the second. These changes were summarized in my earlier response.

Hi arishy,

Nice one. But like I said previously, the dimension I originally used display well on my system. But atleast am glad, ones code is been vetted. Thanks again for your input.

You took the right decision to use table in creating the the elements, this gave you a lot of flexibilty in designing your layout. I will appreciate your help in modifing your script to reflect this flexibily. I do not know where to add <td align=right</td> for the right hand boxes. Can you help ?? P.S. I am just starting PHP initiation!!!!!!

Hi arishy,
To do:

<td align=right></td>

for any of the boxes just do this:

Tr(
        td( { -align => 'right' }, ['Sementer:'] ),
        td(
            { -align => 'center' },
            checkbox_group(
                -name   => 'semester',
                -values => [
                    'Spring 2012',
                    'Summer 2012',
                    'Fall 2013 ',
                    'Spring 2013',
                    'Summer 2013',
                    'Fall 2013',
                    'Spring 2014',
                    'Summer 2014'
                ],
                -defaults => ['Spring 2012'],
                -columns  => 2,
            )
        )
    )

Please note the td(...) parameters.

Can you help ?? P.S. I am just starting PHP initiation!!!!!!

You mean to say Perl?

Worked like a charm...
Well I just love perl, that is my first child, as for PHP it is just born. Thank you for the correction. As you know PHP is the alternative to CGI or that what I think. And for me to evaluate the two approaches, I am planning to do it both ways.
This posting is solved, thanks to you and I do not see where I can flaged it solved, may be because I did not initiate it!!!

Nice to know it works for you.
As regard PHP, you know the first version was actually written in Perl, it was re-engineered in C.
It's also nice if you can do in a new language you learning, what you can do in the previous one you know well.
Enjoy

Thank you all for your inputs. I got the idea.

Hi axn,
Please, mark this trend solved if you are ok with the solutions given.....
Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.