Table cells shrink upon re-opening hidden table in Firefox

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Keysbound

Thread Starter
Joined
Apr 19, 2010
Messages
3
I have a big, intimidating form. To reduce the intimidation factor, I've hidden the fields so that the user can input a little at a time with no confusion.

When the page opens, it looks fine with the table width at 100% and the table cells filling it in fully. The problem is that when I click the link to hide the table, then re-open it, the table cells shrink down to an unexpected size. This happens in all the browsers (except IE). Here is some example code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="CSS/1440x900/input_multiple.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
//=======================================================================================
function showHideTable(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = 'block';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
//Tablolar1 Göster / Gizle.
//========================================================================================
//-->
//
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size:1em;}

table#personalInfo {width:100%}
table#personalInfo tr {width:100%;font-size:1em;}
table#personalInfo th {bgcolor:#2455FF}
table#personalInfo td {width:17%; font-size:1em;}
#apDiv1 {
position:absolute;
width:98%;
z-index:1;
left: 1%;
top: 25%;
}
-->
</style></head>
<body>
<a href="javascript:;" onclick="showHideTable('personalInfo');return false">Personal info</a>
<div id="apDiv1">
<table id="personalInfo" style="display:noner" border="1" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<th class="style38" >Personal Information</td>
<th>&nbsp;</td>
<th>&nbsp;</td>
<th>&nbsp;</td>
<th>&nbsp;</td>
<th>&nbsp;</td>
</tr>
<tr>
<td><div align="right">Spouse's first name:</div></td>
<td><input type="text" name="spouse_first_name" id="spouse_first_name" onfocus="MM_effectHighlight(this, 200, '#ffffff', '#FFFF66', '#FFFF66', true)" value="<?php echo ($row_rsbacchus['spouse_first_name']); ?>" size="16" /></td>
<td><div align="right">1st Spouse's first name:</div></td>
<td><input type="text" name="1st_spouse_first_name" id="1st_spouse_first_name" onfocus="MM_effectHighlight(this, 200, '#ffffff', '#FFFF66', '#FFFF66', true)" value="<?php echo ($row_rsbacchus['1st_spouse_first_name']); ?>" size="16"/></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="right">Race</div></td>
<td ><select name="race" id="race">
<option value="">--Select--</option>
<option value="Asian">Asian</option>
<option value="Alaskan Native">Alaskan Native</option>
<option value="American Indian">American Indian</option>
<option value="Black">Black</option>
<option value="Hispanic">Hispanic</option>
<option value="White">White</option>
</select></td>
<td><div align="right">Height: short; medium or tall</div></td>
<td><select name="height" id="height">
<option value="">--Select--</option>
<option value="short">short</option>
<option value="medium">medium</option>
<option value="tall">tall</option>
</select></td>
<td><div align="right">Birth year: </div></td>
<td><input type="text" name="birth_year" id="birth_year" onfocus="MM_effectHighlight(this, 200, '#ffffff', '#FFFF66', '#FFFF66', true)" value="<?php echo ($row_rsbacchus['birth_year']); ?>" size="16" /></td>
</tr>
</table></div>
</body>
</html>
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
Try changing your "showHideTable()" function to use "display: table" instead of "display: block", which is incorrect for HTML tables:
Code:
function showHideTable(theTable)
{
if (document.getElementById(theTable).style.display == 'none')
{
document.getElementById(theTable).style.display = '[b][color=red]table[/color][/b]';
}
else
{
document.getElementById(theTable).style.display = 'none';
}
}
Your DOCTYPE forces the browser into "Standards" mode, so you'll need to adhere to the web standards to get the desired behavior.

I haven't tried this in IE yet but IE8 should render the page just fine, and IE7 should as well but we'll have to try it to see.

EDIT: IE7 renders the suggested code change above just fine.

EDIT: The above suggested code change doesn't work with IE6 (which is understandable) so you'll need to handle IE6 differently, if you care about IE6 support at all.

Good luck!

Peace...
 

Keysbound

Thread Starter
Joined
Apr 19, 2010
Messages
3
I played around with your suggestion and made it work. Thank you for taking the time to help.
 

tomdkat

Retired Trusted Advisor
Joined
May 6, 2006
Messages
7,148
Cool. What did you end up doing for IE6? Or did you address IE6 at all? :)

Peace...
 

Keysbound

Thread Starter
Joined
Apr 19, 2010
Messages
3
I bagged on IE 6 but I'll look at it in a day or so when I've deployed all this to the various pages that need it. I had nearly finished this project when I decided to review it in FF. Oops... so I'm eager to get it all fixed before tackling that 'final' annoyance.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top