提交按钮高于循环表输入字段
问题描述:
I have got in trouble when I was going to show (print is more suitable) a list of input field within form
.
According to normal situation, there will be a Submit button below it in order to submit the form to (any pages).
Then, I was so confused., because when I use this below code to loop.
<table>
<form>
for($a=1; $a<=10; $a++){
<tr>
<td>
<div class="form-group">
<input class="form-control" type="text" name="name<? echo $a; ?>" required="required"/>
</div>
</td>
<td>
<div class="form-group">
<input class="form-control" type="text" name="url<? echo $a; ?>" required="required"/>
</div>
</td>
</tr>
}
<input type="submit" value="Submit" class="btn btn-primary"/>
</form>
</table>
And the Submit button is on the top of the form?! Can any help me to fix it?
Or...at least some reason?
答
Update your code like
<tr>
<td colspan="2">
<input type="submit" value="Submit" class="btn btn-primary"/>
</td>
</tr>
it will display submit button below the input field.
答
You have incorrect order of html tags.
<table>
<form>
<tr>
...
</tr>
<input type="submit" value="Submit" class="btn btn-primary"/>
</form>
</table>
<table>
tag can only contain (in this particular order)
- an optional
<caption>
element, - zero or more
<colgroup>
elements, - an optional
<thead>
element, - either one of the following:
- zero or more
<tbody>
elements - one or more
<tr>
elements
- zero or more
- an optional
<tfoot>
element
Try reordering your elements like this:
<form>
<table>
<tr>
...
</tr>
</table>
<input type="submit" value="Submit" class="btn btn-primary"/>
</form>