0
如何使用jQuery访问多个更新的表单值?使用jquery访问多个表单值
我有一个jsp形式的文本框显示保存的值。当这些值更新时,我需要访问更新的值。 jsp的文本框如下:
<html:text maxlength="11" size="11" property="user.pastAmt" onchange="showInfo();" />
<html:text maxlength="11" size="11" property="user.currAmt" onchange="showInfo();" />
在showInfo功能,我需要访问值都user.pastAmt和user.currAmt,无论在哪里onchange事件是由触发:
function showInfo() {
alert('pastAmt: ' + $("[name='user.pastAmt']").val());
alert('currAmt: ' + $("[name='user.currAmt']").val());
}
问题是,如果我像上面那样访问它,我只显示保存的值,而不显示更新的值。
我发现我可以发送更新的值中的一个使用“this”关键字的事件:
<html:text maxlength="11" size="11" property="user.pastAmt" onchange="showInfo(this);" />
<html:text maxlength="11" size="11" property="user.currAmt" />
有了:
function showInfo(pastA) {
alert('pastAmt: ' + $(pastA).val());
alert('currAmt: ' + $("[name='user.currAmt']").val());
}
但是我怎么访问其他?
非常感谢!这足以让我重新开始! – sharcfinz 2015-02-10 23:46:10