DIV内外的HTML多种形式

时间:2014-07-09 04:01:16

标签: javascript html css forms

我正在尝试做以下事情:

<div id="div1"....>
   <div id="div2"....>
      <form name="form1" .....>
         <input type="text">
         <input type="submit" value="submit1">
      </form>

      <form name="form2" .....>
         <input type="text">
   </div>  //End of Div2
   <div id="div3" ...>
         <input type="submit"  value="submit2"......>
      </form> //End of form2
   </div> //End of Div3
</div> //End of Div1

但每次form关闭都在div2内。因此,submit input来自form,点击后未提交form。请帮忙。

根据我的项目需要,我的div职位在这里。有没有办法维持formdiv按钮/关闭submit以外的div开头?

3 个答案:

答案 0 :(得分:0)

form的开始和结束标记应位于同一div

尝试这样的事情:

<div id="div1"....>
   <div id="div2"....>
      <form name="form1" .....>
         <input type="text">
         <input type="submit" value="submit1">
      </form>
   </div>  //End of Div2
   <div id="div3" ...>
      <form name="form2" .....>
         <input type="text">
         <input type="submit"  value="submit2"......>
      </form> //End of form2
   </div> //End of Div3
</div> //End of Div1

答案 1 :(得分:0)

您的代码应如下所示。

<div id="div1"....>
   <div id="div2"....>
      <form name="form1" .....>
         <input type="text">
         <input type="submit" value="submit1">
      </form>

      <form name="form2" .....>
         <input type="text">   
   <div id="div3" ...>
         <input type="submit"  value="submit2"......>
   </div>  //End of Div3
      </form> //End of form2
   </div> //End of Div2
</div> //End of Div1

答案 2 :(得分:0)

我不确定你究竟需要什么,但我清理了一下,也许这就是你要找的东西:

<div id="div1">
       <form> 
            <input type="text" name="from1">
            <input class="submit" type="submit" value="Submit1">
       </form>
</div>
<div id="div2"> 
       <form> 
            <input type="text" name="from2">
            <input class="submit" type="submit" value="Submit2">
       </form>
</div>