Jump to content

<OL>/<LI> Alignment Issue


xProteuSx

Recommended Posts

I hope I can make someone understand what the problem is ... its 1 am and I am crashing hard.  The whole problem is that this snippet really does not like the <ol type="a"> outside of the 'while' loop.  What I am trying to do is, say the array has 4 variables, I would like a., b., c., and d., to appear to the left of the <input type="radio" name="answer" value="' . $value . '"> button(s).  Now, I am getting something there, but I am getting 0., 0., 0., and 0. instead of the letters.

 

Please help!!!!  Thanks in advance.

 

echo '<center>';
echo '<form action="mark_spec.php">';
echo '<ol type="a">';

while (list($key,$value) = each($answers_array))
{
echo '<table width="400" cellspacing="0" cellpadding="2">';
echo '<tr>';
echo '<td valign="top">';
echo '<li>';
echo '<font size="-1"> <input type="radio" name="answer" value="' . $value . '"></font>';
echo '</td>';
echo '<td valign="top">';
echo '<font size="-1">' . $value . '</font>';
echo '</li>';
echo '</td>';
echo '</tr>';
echo '</table>';
}

echo '</ol>';
echo '<input type="submit" value="Check Answer">';
echo '</form>';
echo '</center>';

 

Link to comment
Share on other sites

that is because type is a deprecated attribute of the ol tag - just give it a class or an id to style it instead.

 

ol should contain li elements NOT TABLES - TABLES ARE FOR TABULAR DATA.

 

on a slightly different point - don't scared of breaking out of php - it can really help you see things better AND improve efficiency...

 

Now - I don't like you html but that is another matter but you code could be written like so

 

<center>
<form action="mark_spec.php">
<ol type="a">
<?php
while (list($key,$value) = each($answers_array))
{
?>
  <table width="400" cellspacing="0" cellpadding="2">
   <tr>
    <td valign="top">
     <li>
      <font size="-1"> <input type="radio" name="answer" value="' . $value . '"></font>';
    </td>
    <td valign="top">
     <font size="-1"><?php echo  $value; ?></font> 
    </li>
    </td>
</tr>
</table>
<?php
}
?>									
</ol>
<input type="submit" value="Check Answer"> 
</form>
</center>

 

Now please go an produce some html that actually means something - I can see wat you are trying to do - suffice to say you are not going the right way about it - have a go at producing VALID and MEANINGFUL markup and then we might be able to help you a little more...

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.