如何在 java Web 应用程序中使用 Ajax 将文本字段的值与 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。
相关文章:
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 而循环只设置php中输入字段中的第一个值
- 在输入字段中将最小金额设置为
- 从Rally获取一个特定的标记,以便计算另一个字段中的值
- 如何在输入字段中的按钮的帮助下打开日历,该字段的类型为“=”;日期”;
- JavaScript 检查隐藏字段中的值并将其设置为隐藏字段值
- 在wordpress一定时间后更改自定义字段
- 如何在HTML输入字段中添加不可删除的后缀
- Meteor-添加用户自定义字段的方法不起作用
- 互斥单选按钮和相应的输入字段
- 在IE9中的输入字段中输入焦点最近按钮
- 选中单选框时将属性添加到输入字段
- 带有验证和隐藏字段值的提交按钮
- 主干窗体隐藏字段未呈现
- 带有let的JS/EECMAScript6私有字段的模式
- 按钮字段确认点击不'不起作用
- 如何从一个 HREF 填充多个输入字段
- 将输入字段设置为包含 window.location.href
- 如果使用“href”提交页面,则不会发布隐藏字段
- 如何将HREF设置为来自输入字段和选择列表的文本?