Jump to content


Photo

Help With Table Percent


  • Please log in to reply
8 replies to this topic

#1 kalster

kalster

    Advanced Member

  • Members
  • PipPipPip
  • 75 posts

Posted 21 November 2012 - 04:49 AM

I have a problem of course :). the table width is not displayed correctly. The collumes (i think i said that correctly) is not displaying at 20%. the width of the table is not displaying correctly. at the last input, the width is not the same as the other width. i hope your understand. thank you. the table is displayed, but the last feild is not at the 20% like the rest.
<table width="100%" border="1">
<form action="event.php" method="post" name="event" id="event">
<tr>
<td width="%20">Crime</td>
<td width="%20">Money</td>
<td width="%20">Chance</td>
<td width="%20">Burglar men</td>

<td width="%20"><input type="submit" value="submit"></td>
</tr>
</form>
</table>


#2 rjmcintyre7

rjmcintyre7

    Newbie

  • New Members
  • Pip
  • 6 posts

Posted 21 November 2012 - 12:40 PM

When you run into issues like this, try going to: http://validator.w3.org/check to see if your code is valid before posting here. I placed your code into the validator (with the doctype reference and full html tags) and received a few errors that may or may not be causing your issue. Here is the snippet that passed validation:

<form action="event.php" method="post" name="event" id="event">
<table width="100%" border="1">
<tr>
<td width="%20">Crime</td>
<td width="%20">Money</td>
<td width="%20">Chance</td>
<td width="%20">Burglar men</td>
<td width="%20"><input type="submit" value="submit" /></td>
</tr>
</table>
</form>

Your form tag should be outside of your table AND you should have a closing "/" on your input. See if that takes care of your layout issue. And while it isn't a validation issue, you should choose to put the "%" consistently before or after the number to make it easier to view for others - after the number is most widely accepted, but either way, try not to go back and forth like in this example (i.e. 100% and %20).

Edited by rjmcintyre7, 21 November 2012 - 12:42 PM.


#3 Love2c0de

Love2c0de

    Advanced Member

  • Members
  • PipPipPip
  • 366 posts
  • LocationThe Pleiades
  • Age:23

Posted 24 November 2012 - 03:47 PM

When I changed your <td width="20%">, all the table data's seem to now have the same width.

Was never aware '%20' was allowed.

Regards,

AoTB.

Edited by AoTBuNgLe, 24 November 2012 - 03:48 PM.


#4 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 24 November 2012 - 03:55 PM

It would seem its not ;)
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#5 smallc28

smallc28

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 25 November 2012 - 01:24 AM

<table width="100%" border="1">
<form action="event.php" method="post" name="event" id="event">
<tr>
<td width="20%">Crime</td>
<td width="20%">Money</td>
<td width="20%">Chance</td>
<td width="20%">Burglar men</td>

<td width="20%"><input type="submit" value="submit"></td>
</tr>
</form>
</table>

#6 smallc28

smallc28

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 25 November 2012 - 01:28 AM

My guest is to make submit button width "smaller since its a small button
<table width="96%" border="1">
<form action="event.php" method="post" name="event" id="event">
<tr>
<td width="20%">Crime</td>
<td width="20%">Money</td>
<td width="20%">Chance</td>
<td width="31%">Burglar men</td>
<td width="9%"><input type="submit" value="submit"></td>
</tr>
</form>
</table>

#7 MDCode

MDCode

    Advanced Member

  • Members
  • PipPipPip
  • 645 posts

Posted 25 November 2012 - 12:11 PM

You are setting your table width to 96% yet it adds up to 100%

#8 Xaotique

Xaotique

    Advanced Member

  • Members
  • PipPipPip
  • 572 posts
  • LocationPennsylvania, United States
  • Age:22

Posted 25 November 2012 - 08:24 PM

You are setting your table width to 96% yet it adds up to 100%

Say the table at 96% was 1000px wide. If you set a TD to 20%, it will be 20% of that 96% or 1000px which is a TD with a width of 200px.

#9 kalster

kalster

    Advanced Member

  • Members
  • PipPipPip
  • 75 posts

Posted 26 November 2012 - 04:47 PM

thank you. i fixed the table width by changing %20 to 20%. this topic is solved.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com