tags:

views:

41

answers:

2

I have a dynamic form that i am creating in php then i have a static button after that. However, the button is appearing on top of the dynamic form.

The code for the button is simple, it is :

echo "<input type=\"submit\" value=\"Click here\" />
     </table></form>";

but i don't understand why does the button appear on the top of the form instead of appearing on the bottom even though its code is after the php code for creating the form, is there anything i could test or do to change that?

+1  A: 

Well, firstly the code snippet you've got there isn't valid. I can tell that immediately. You've got an input as a child to a table. Can't do that. The browser is then treating that like it's meant to be before or after or something. You need:

<table>
...
<tr>
  <td><input type="submit" ... ></td>
</tr>
</table>

or something like that. Only TR, TBODY, THEAD, TFOOT, COLGEROUP and COL elements are legal child elements of a table.

You may also have a problem with not closing tags or closing them in the wrong order higher up in the document. Not closed:

<p>This is a <b>test</p>

Wrong order:

<p>This is a <b><i>test</b></i></p>

although browsers can usually figure these ones out, once you start getting into tables and more complicated structures any missing or wrong closing tag can throw the whole thing out.

cletus
+2  A: 

I can only guess from the little bit of code that you have posted, but it looks like you dont have your submit button in a <td>. Usually when you put html elements inside of a table, and not inside of the td, it puts it on top, or below the whole table. The way it should be done is like this:

     echo "<tr>
              <td><input type=\"submit\" value=\"Click Here\" /></td>
           </tr>
         </table>
       </form>";
iangraham