Solved

Putting text input fields in a table

Posted on 2008-06-23
3
184 Views
Last Modified: 2010-04-09
Hi,

I want to put a few text labels and text fields within a table. Something like:

-------------------------------------
|  Text Label   |  Input field   |
-------------------------------------
|  Text Label   |  Input field   |
-------------------------------------
|  Text Label   |  Input field   |
-------------------------------------

Right now I just threw something on a page like:

<form name="testForm" action="doit.php" method="get">
        TextLabel1: <input type="text" name="txt1">
        <br/>
        Input1: <input type="text" name="input1">
        <br/>
        TextLabel2: <input type="text" name="txt2">
        <br/>
        Input2: <input type="text" name="input2">
        <br/>
</form>

Yeah how can I get it in a table to look a little nicer but still access the fields for the form to submit?

Thanks
0
Comment
Question by:DJ_AM_Juicebox
3 Comments
 
LVL 10

Accepted Solution

by:
margajet24 earned 500 total points
ID: 21852489
<form name="testForm" action="doit.php" method="get">
<table border= 1>

<tr>
 <td>TextLabel1:</td>
 <td> <input type="text" name="txt1"></td>
</tr>


<tr>
 <td>Input1:</td>
 <td><input type="text" name="input1"></td>
</tr>

<tr>
 <td>TextLabel2:</td>
 <td><input type="text" name="txt2"></td>
</tr>

<tr>
 <td>Input2:</td>
 <td> <input type="text" name="input2"></td>
</tr>


</table>
</form>
0
 
LVL 18

Expert Comment

by:Rartemass
ID: 21852506
The best way to do this is with CSS.

What are you using to make the page? Dreamweaver; Flash; Frontpage; Notepad; Word?

Via Dreamweaver:
Wrap the form in a <div> tag.
Create a new CSS file.
Click on the element name eg Input1, and add it to the CSS file. Configure the position properties via the CSS pop-ups in Dreamweaver.

You can play with the settings to make it look like you want.

If you don't have Dreamweaver or a program that shows you a graphical representation of the code you will need to do it all in html.
If you are familiar with CSS then you can still do this with notepad, but it can become time consuming.

I cringe as I'm typing this but you can use a simple table in html. See attached code for example syntax.
Tables are very old and were a good way to do this a decade or more ago, but they can create more problems than they are worth. It should be OK for a simple form though.

I would recommend at least getting the trial version of Dreamweaver from Adobe and use the CSS method. You will appreciate the control you can get out of it. It also adds all the extra code into the HTML file in case you forget something.

<table border="1">

<tr>

<td>row 1, cell 1</td> /* Label*/

<td>row 1, cell 2</td> /* Field*/

</tr>

<tr>

<td>row 2, cell 1</td> /*Label*/

<td>row 2, cell 2</td> /*Field*/

</tr>

</table>

Open in new window

0
 

Expert Comment

by:mwr
ID: 21855311
I agree with Rartemass for the css,

but for the rest you don't need all these paying programs yet (well I don't think so...you tell me how complicated you want your site to look )

Aparently what you want is something like this:
<form name="testForm" action="doit.php" method="get">

<!-- ... -->

<table border="1">

  <tr>

    <td>Textlabel 1</td>

    <td><input type="text" name="input1"></td>

  </tr>

  <tr>

    <td>Textlabel 2</td>

    <td><input type="text" name="input2"></td>

  </tr>

  <tr>

    <td>Textlabel 3</td>

    <td><input type="text" name="input3"></td>

  </tr>

</table>

<!-- etc -->

</form>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now