dongtuojuan8998
dongtuojuan8998
2018-10-09 06:36
浏览 22
已采纳

提交按钮高于循环表输入字段

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>

Tadaa...then it shows: enter image description here

And the Submit button is on the top of the form?! Can any help me to fix it?

Or...at least some reason?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongxi1879
    dongxi1879 2018-10-09 06:42
    已采纳

    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.

    点赞 评论
  • duanjia3187
    duanjia3187 2018-10-09 08:21

    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
    • 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>
    
    点赞 评论

相关推荐