簡體   English   中英

如何在Java Web App中使用Ajax將textfield的值和href值一起帶到下一頁?

[英]How do I take the value of textfield along with the href value to the next page using Ajax in java web app?

我在Java Web應用程序中使用Ajax,我想獲取textfield的值以及指向下一頁的href鏈接。

<%@page contentType="text/html" pageEncoding="UTF-8"%>
           <% String root = getServletContext().getContextPath();
           %>
              <table  border="0" id="box-table-b">
                  <thead><tr>
                  <th height="31" colspan="2" nowrap>Enter User Id of Patient </th>
                      </tr></thead>
                <tr>`enter code here`
                  <td width="76" nowrap>UserId</td>
                  <td width="85"  nowrap>
                      <input type="text" name="confuserid" id="confuserid"/>
                 </td>
                </tr>
                <tr>
                <td height="66" colspan="2" align="center" valign="middle" nowrap>            
                <a href="#" onclick="returndisplayData('<%=root%>/confapp.do?method=confapp','entry');"><input type="button" value="Submit"></a>
                  </td>
                </tr>
              </table>

您可以將控件和鏈接放置在表單中,然后通過GET提交表單,但這將使您擺脫ajax的困擾。

另一個選擇是簡單地使用jQuery獲取confuserid的值,並將其附加到傳遞給returndisplayData函數的URL上。

就像是

function getMyURL() {
    return '<%=root%>/confapp.do?method=confapp&confuserid='+$("#confuserid").val();
}

然后您的鏈接看起來像

<a href="#" onclick="returndisplayData(getMyURL(),'entry');"><input type="button" value="Submit"></a>

顯然,您需要在頁面中包含jQuery。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM