Jquery无法设置隐藏字段值
Jquery not able to set hidden field values
我在尝试使用Jquery甚至使用纯java脚本设置隐藏字段时遇到了一个奇怪的问题
我的JSP页面中有两个隐藏字段
<input type="hidden" name="firstSelectedPaymentId" id="firstSelectedPaymentId1" value=""/>
<input type="hidden" name="secondSelectedCCPaymentId" id="secondSelectedCCPaymentId" value=""/>
这就是我在JS 中设置隐藏值的方式
if ($('#firstSelectedPaymentId1').length > 0) {
$('#firstSelectedPaymentId1').val(response.result.selectedPaymentInfoId);
}
if ($('#secondSelectedCCPaymentId').length > 0) {
//$('#secondSelectedCCPaymentId').val(response.result.selectedPaymentInfoId);
document.getElementById('secondSelectedCCPaymentId').value=response.result.selectedPaymentInfoId;
}
对于第一种情况,它运行良好,但对于secondSelectedCCPaymentId
,它没有在隐藏字段中设置任何值。
我已经检查了我的JSP,并且没有具有相同id的字段,此外,如果我尝试
alert($('#secondSelectedCCPaymentId').val());
我可以在像5466565665666
这样的警报框中看到值。response.result.selectedPaymentInfoId
是系统生成的值,它是由我已经验证的系统生成的。我不确定我哪里做错了,或者为什么它没有在隐藏字段中设置值?
if ($('#firstSelectedPaymentId1').length > 0) {
$('#firstSelectedPaymentId1').text(response.result.selectedPaymentInfoId);
}
if ($('#secondSelectedCCPaymentId').length > 0) {
//$('#secondSelectedCCPaymentId').text(response.result.selectedPaymentInfoId);
document.getElementById('secondSelectedCCPaymentId').value=response.result.selectedPaymentInfoId;
}
相关文章:
- JavaScript 检查隐藏字段中的值并将其设置为隐藏字段值
- 带有验证和隐藏字段值的提交按钮
- 主干窗体隐藏字段未呈现
- 清除以前的$_GET值或不获取仅隐藏字段的值
- 添加和删除隐藏字段数组中的值,而不提交表单
- 在控制器上使用“$watch”时,为什么不更新此隐藏字段
- 将选项值附加到隐藏字段
- JQuery获取隐藏字段的值
- HTML提交表单,同时包含空字段检查和按钮隐藏
- MVC+访问控制器中的隐藏字段
- 如何隐藏&使用jQuery禁用依赖于另一个字段值的字段
- ASP.net Javascript函数中的隐藏字段为null
- 在第一页加载时隐藏字段,而不是在php发布之后
- 使用JavaScript获取隐藏的Django字段
- 提交表单时,显示或识别隐藏的必填字段并将其集中
- 表单使用js、html,而不是隐藏字段
- HTML5要求隐藏文件字段-反馈位置
- 当javascript中的强制字段隐藏在条件中时,如何限制它们的验证
- 为隐藏字段隐藏jquery验证器消息
- 如何使一些字段隐藏取决于其他字段的值AngularJS, Razor, c#