Jump to content

Table is lining rows next to each other


smproph

Recommended Posts

I made a simple form and a table. Well for some reason Firefox is lining two of my rows next to each other but Safari puts the row below each other like it should be and I can't figure out if its a firefox thing or my code. Here it is

<form action="" method="post" name="question"> 
<table>
<tr>
<td>Do you have Children</td>
</tr>
<tr>
<td>Yes
<input name="children" type="radio" value="yes"  onclick = "if(document.getElementById('children').style.display=='none') 
       {
       document.getElementById('children').style.display='inline';
       document.getElementById('children2').style.display='inline';
       } " />

    No
<input name="children" type="radio" value="no"   onclick = "if (document.getElementById('children').style.display='inline') 
       {
       document.getElementById('children').style.display='none';
       document.getElementById('children2').style.display='none';
       } " />
</td>
</tr> 

<tr id="children" style="display:none;">
<td>Name<br/><input type="text" name="name" /></td>
<td>DOB<br/><input type="text" name="dob" /></td>
<td>Age<br/><input type="text" name="age" /></td>
</tr>
<tr id="children2" style="display:none;">
<td>Social<br/><input type="text" name="social" /></td>
<td>DL<br/><input type="text" name="dl" /></td>
</tr>
<tr>
	<td>Do you have pets</td>
</tr>
<tr>
<td>Yes<input name="pets" type="radio" value="yes"  onclick = "if(document.getElementById('pet').style.display=='none') 
       {
       document.getElementById('pet').style.display='inline';
       } " />

No
<input name="pets" type="radio" value="no"   onclick = "if (document.getElementById('pet').style.display='inline') 
       {
       document.getElementById('pet').style.display='none';
       } " />
       </td>
</tr>
<tr id="pet" style="display:none;">
<td>Name<br/><input type="text" name="name" /></td>
<td>Type<br/><input type="text" name="dob" /></td>
<td>Age<br/><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>

 

Link to comment
Share on other sites

<form action="" method="post" name="question"> 
<table>
<tr>
<td>Do you have Children</td>
</tr>
<tr>
<td>Yes
<input name="children" type="radio" value="yes"  onclick = "if(document.getElementById('children').style.display=='none') 
       {
       document.getElementById('children').style.display='block';
       document.getElementById('children2').style.display='block';
       } " />

    No
<input name="children" type="radio" value="no"   onclick = "if (document.getElementById('children').style.display='inline') 
       {
       document.getElementById('children').style.display='none';
       document.getElementById('children2').style.display='none';
       } " />
</td>
</tr> 

<tr id="children" style="display:none;">
<td>Name<br/><input type="text" name="name" /></td>
<td>DOB<br/><input type="text" name="dob" /></td>
<td>Age<br/><input type="text" name="age" /></td>
</tr>
<tr id="children2" style="display:none;">
<td>Social<br/><input type="text" name="social" /></td>
<td>DL<br/><input type="text" name="dl" /></td>
</tr>
<tr>
	<td>Do you have pets</td>
</tr>
<tr>
<td>Yes<input name="pets" type="radio" value="yes"  onclick = "if(document.getElementById('pet').style.display=='none') 
       {
       document.getElementById('pet').style.display='inline';
       } " />

No
<input name="pets" type="radio" value="no"   onclick = "if (document.getElementById('pet').style.display='inline') 
       {
       document.getElementById('pet').style.display='none';
       } " />
       </td>
</tr>
<tr id="pet" style="display:none;">
<td>Name<br/><input type="text" name="name" /></td>
<td>Type<br/><input type="text" name="dob" /></td>
<td>Age<br/><input type="text" name="age" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>

Link to comment
Share on other sites

seems he changed after Yes in your first JS onClick to block from inline:

 

       document.getElementById('children').style.display='block';
       document.getElementById('children2').style.display='block';

 

Also, you have 

if (document.getElementById('children').style.display='inline

in there twice as if(element = 'inline')  This will always return true and you will want to make it == like in the others. Just a bug you might not have caught yet.

Link to comment
Share on other sites

yeah sorry for not explaining, i was in a rush.

 

the javascript changes the styling from display:none to display:inline

 

i simply tweaked it from display:inline to display:block so that it made sure it went underneath.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.