Forum Moderators: open

Message Too Old, No Replies

LABEL Setting for Two Fields

         

itgl72

2:48 pm on May 4, 2005 (gmt 0)

10+ Year Member



What is the proper way to use LABEL for two fields and make it look the way I want below (two fields inline) I know how to LABEL when it is one field but if it is two fields what is the proper way to set this up for FIRSTNAME and LASTNAME fields? If someone can show me an example from the code I have below it would be an eye opener.

<table>
<tr>
<td class="labelcell"><label for "full name">Full Name:</label></td>
<td class="smallfieldcell"><input type="text" name="firstname" id="first name" tabindex="1" />
<input type="text" name="lastname" id="last name" tabindex="1" /></td>
</tr>
</table>

Stormfx

5:48 pm on May 4, 2005 (gmt 0)

10+ Year Member



Getting the two text boxes to show up inline has nothing to do with the label field. Just make sure that the <td> is wide enough to fit them both. You can set the alignment on the td to control their position, like so:

<td align="left" valign="middle">

If one still drops down a line, try using nowrap="nowrap" in the <td> tag.

HTH

itgl72

6:09 pm on May 4, 2005 (gmt 0)

10+ Year Member



Well everything fits OK. My issues is knowing what to put in the ID field for firstname,last name if theres just one label that says full name.

Stormfx

8:17 pm on May 4, 2005 (gmt 0)

10+ Year Member



A label is an element totally independant of the text boxes. The label has no effect on the text boxes, either visually or script-wise. Likewise, the text boxes have no effect on the label. For submission of the form, the identifying attribute is 'name', not 'id'. ID would be used for things like styling and javascript.

To set them up, you'd do something like:

<label>Full Name</label><input name="fname" type="text"><input name="lname" type="text">

But as far as ID tags, each textbox, label, etc is its own element, therefore needs it own ID. e.g.:

<label id="nameLabel">Full Name</label><input name="fname" id="fName" type="text"><input name="lname" id="lName" type="text">

But like I said, you only need ID tags for javascript or CSS.