Help - Search - Members - Calendar
Full Version: Formatting textbox (form)
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
hop
I'm a little new to html, and forms, and I needed to create a page that would allow me to change data in a file I use in my PHP based website.

First order of business was to parse the data file into arrays, and then echo it to a page. No problem there, and after googling forms, I figured out how to dynamically create a table, and populate it with data and textboxes. That is where I hit a brick wall.

All my table cells are too big because the standard textbox seems to have a blank line under it, as if <BR> was after the textbox. I have no idea how to correct that.

Then I realized that there are many sites I have visited, this one included, that has that perfect textbox I want. Single pixel border, flat appearance, no mysterious line-feed under it.

Can someone tell me where I can find the information I need to use that type of textbox in my project? It would make it look so much "cleaner", and I would be able to view much more information without having to scroll so much.

Thanks for the time.

Here is a snippet from my PHP page
CODE

?>
<table border="1" width="900" id="table1" cellspacing="0" cellpadding="0">
<?
foreach ($headlist as $piece)
    {
        $t1=explode(chr(7), $piece)?>
        <tr>
        <td height="10" width="200">
        <?echo rtrim($t1[0])?>
        </td>
        <td align="left" height="0" width="700">
        <form method="post">
        <input type="textbox" style="border: none" size=50 name="<?echo rtrim($t1[0])?>" value="<?echo rtrim($t1[1])?>">
        </td>
        </form>
        </tr>
        <?
        $headdata[rtrim($t1[0])]=rtrim($t1[1]);
    }
?></table><?


Hop
Christian J
The FORM element has a default bottom margin in many browsers, but you can remove it with CSS.

You must also close the FORM inside the TD element you opened it in, so instead of


CODE
</td>
</form>
</tr>


use

CODE

</form>
</td>
</tr>
hop
QUOTE(Christian J @ Oct 10 2006, 02:57 AM) *

You must also close the FORM inside the TD element you opened it in...


Yeah, oops. blink.gif It still worked too.
That's what I get for writing new types of code after midnight. unsure.gif

Thanks for the help!
hop
QUOTE(Christian J @ Oct 10 2006, 02:57 AM) *

The FORM element has a default bottom margin in many browsers, but you can remove it with CSS.


Yes indeed, and you can do a whole lot more than I could imagine.

I had to use a value of -9pt to get the effect I needed which I thought was odd.

Thanks for pushing me in the right direction. biggrin.gif

Hop
Christian J
QUOTE(hop @ Oct 10 2006, 06:26 PM) *

I had to use a value of -9pt to get the effect I needed which I thought was odd.


Why not use a zero margin?

CODE
form {margin: 0;}


In any case the pt unit is meant for printed media, px is a better choice for screen.
Darin McGrew
QUOTE
In any case the pt unit is meant for printed media, px is a better choice for screen.
I would argue against px, except in the rare situations where something is being sized to match an image.
hop
QUOTE(Christian J @ Oct 10 2006, 09:58 AM) *

Why not use a zero margin?

CODE
form {margin: 0;}


In any case the pt unit is meant for printed media, px is a better choice for screen.


Hmm. There are a few ways to do it apparently. I just set up a style in the header...
CODE
<head>
<style type="text/css">
<!--
INPUT {
background-color: #D8BFFF;
color: #000080;
border: black 1px solid;
font-family: arial, verdana, ms sans serif;
font-weight: normal;
font-size: 8pt;
margin-bottom: -9pt;
padding-left: 2
}
-->
</style>
</head>


I hadn't thought about what would happen if I wanted different styles of textboxes on the same page however, so I guess I better read up on doing these CSS things within the form tag, yes?
I hadn't thought about pt verses px either. All I know is when I used margin-bottom: 0pt; I was where I started in the first place.

One last thing... is there a way to change the appearance of the scrollbar in a textarea control?

I appreciate the time you guys have spent helping me with my newby HTML issues. I really need to take a few days of my vacation and look more closely at HTML and what is possible. Funny also that this page I'm testing is the first one I have ever written from scratch, without FrontPage, or GoLive. I'm using Dev-PHP IDE instead, with Apache and PHP 5 running on one of my machines on my LAN as a server.

Hop
Darin McGrew
Please see the FAQ entry How can I specify my scrollbar colors?
Christian J
QUOTE(hop @ Oct 10 2006, 08:56 PM) *

CODE

<style type="text/css">
<!--
INPUT {
background-color: #D8BFFF;
color: #000080;
border: black 1px solid;
font-family: arial, verdana, ms sans serif;
font-weight: normal;
font-size: 8pt;
margin-bottom: -9pt;
padding-left: 2
}
-->
</style>
</head>



The above affects INPUT elements, not the FORM container. The negative INPUT margin pulls up the bottom of the FORM, but different amounts in different browsers it seems.

You also lack a unit on the padding value. Here's a tool for finding CSS errors: http://jigsaw.w3.org/css-validator/

QUOTE
I hadn't thought about pt verses px either.


IMO px is fine for screen, but if you want a width, margin or padding to adapt to varying user font sizes you should use em. For font-sizes you shouldn't use px or pt, use percent or nothing.

QUOTE
All I know is when I used margin-bottom: 0pt; I was where I started in the first place.


That's probably because you specified it for the INPUT, not the FORM.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.