java - JSP - Twitter Bootstrap 模态表单处理

标签 java html css jsp twitter-bootstrap

我想用 jsp 处理模态表单。我的问题是,按钮位于另一个 div 中,因此不会呈现 servlet“/user”。

<div class="modal-body">
    <form class="form-horizontal" action="/user" method="post">
          <fieldset>
              <div class="control-group">
                 <!-- Text input-->
                 <label class="control-label" for="input01">Email:</label>
                      <div class="controls">
                           <input name="email" placeholder="email" class="input-xlarge" type="text"value="<%=request.getParameter("email")%>">
                     </div>
             </div>

             <div class="control-group">
                  <!-- Text input-->
                  <label class="control-label" for="input01">Password:</label>
                         <div class="controls">
                              <input name="password" placeholder="password" class="input-xlarge" type="text" value="<%=request.getParameter("password")%>">
                         </div>
            </div>

        </fieldset>
   </form>
</div>

如何正确写出我可以使用另一个div中的按钮来提交表单?

最佳答案

您可以在表单上放置一个 id 属性,在按钮的 onclick 事件上您可以调用 document.forms["formId"].submit() 或 jQuery $('#formId').submit()

<form id="myForm" class="form-horizontal" action="/user" method="post"> //add id attr

在你的按钮上试试这个:

<input type='button' value='submit' onclick='document.forms["myForm"].submit();'/>

或使用 jQuery:

<input type='button' value='submit' onclick='$("#myForm").submit();'/>

关于java - JSP - Twitter Bootstrap 模态表单处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15568683/

相关文章:

java - 连接常量字符串 VS StringBuffer

java - 自定义表模型中的 JComboBox

java - 如何使用 Java NIO 从嵌套的 zip 文件中读取文件

javascript - HTML Bootstrap 表单 : how to add spacing between elements, 增加文本区域的大小?

javascript - 为什么我用 window.onresize 触发事件时得到了错误的 window.height 值?

html - 如何限制悬停一次不应用于所有链接?

java - 如何在 Eclipse 中的 git 分支之间进行纯文本比较(使用 EGit)

Javascript确认框,如果点击取消,则不会重新加载页面

html - 将 "text-overflow: ellipsis;"应用于内部 div

css - 用于 Oracle 数据库应用程序的 Rich Internet Application (RIA)