在jsp页面遍历时,用JS取值问题

J2EE 码拜 6年前 (2016-06-04) 1050次浏览
点击打印回单的链接,用js通过ID取值,为什么之能取到第一个遍历项的值,本人才是遍历时ID时重复的,但不知道怎么解决。

<c:forEach var="pacPayOrder" items="${orderPageList.root}" varStatus="status">
						<tr>
							<td width="8%;"class="blue on">${pacPayOrder.payapplyid}</td>
							<td width="8%;" align="center" >${pacPayOrder.payamount}</td>
							<td width="12%;" class="">${pacPayOrder.rcvname}</td>
							<td width="12%;" class="">${pacPayOrder.sysstatusdesc}</td>
							<td width="12%;" class="">${pacPayOrder.paytypedesc}</td>
							<td width="12%;" class=""><fmt:formatDate value="${pacPayOrder.createtime}" pattern="yyyy-MM-dd"/></td>
							<td width="10%;"><a href="javascript:;" class="green" onclick="detail(${pacPayOrder.payorderid})">查看支付订单细明</a></td>
							<td width="8%;" class="blue on"><a href="#" >业务订单细明</a></td>
							<td width="8%;" class="blue on"><a href="javascript:;" class="green" onclick="receipt()" >打印回单</a>
								<input type="hidden" id="paybankaccount" value="${pacPayOrder.paybankaccount}">
								<input type="hidden" id="payorderid" value="${pacPayOrder.payorderid}">
								<input type="hidden" id="createtime" value="${pacPayOrder.createtime}">
							</td>
						</tr>
					</c:forEach>

下面时JS代码

function receipt() {

				var payorderid = $("#payorderid").val();
				var paybankaccount = $("#paybankaccount").val();
				var createtime = $("#createtime").val();
				parent.layer.open({
					type : 2,
					skin: "layui-layer-gray",
					title: ["回单查询","font-size:20px;text-align:center;color:#424f62;font-weight:bolder"],
					shade: [0.6,"#767575"],
					maxmin: true,
					scrollbar:false,
					shift: 2 ,
					area: ["400px", "300px"],
					content : "${ctx}/receipt.do?payorderid=" + payorderid + "&paybankaccount=" + paybankaccount +"&createtime=" + createtime
				});
			}
		</script>
解决方案

40

直接传参:

<c:forEach var="pacPayOrder" items="${orderPageList.root}" varStatus="status">
	<tr>
		<td width="8%;"class="blue on">${pacPayOrder.payapplyid}</td>
		<td width="8%;" align="center" >${pacPayOrder.payamount}</td>
		<td width="12%;" class="">${pacPayOrder.rcvname}</td>
		<td width="12%;" class="">${pacPayOrder.sysstatusdesc}</td>
		<td width="12%;" class="">${pacPayOrder.paytypedesc}</td>
		<td width="12%;" class=""><fmt:formatDate value="${pacPayOrder.createtime}" pattern="yyyy-MM-dd"/></td>
		<td width="10%;"><a href="javascript:;" class="green" onclick="detail(${pacPayOrder.payorderid})">查看支付订单细明</a></td>
		<td width="8%;" class="blue on"><a href="#" >业务订单细明</a></td>
		<td width="8%;" class="blue on"><a href="javascript:;" class="green" onclick="receipt("${pacPayOrder.paybankaccount}","${pacPayOrder.payorderid}","${pacPayOrder.createtime}")" >打印回单</a>
			<input type="hidden" id="paybankaccount" value="">
			<input type="hidden" id="payorderid" value="">
			<input type="hidden" id="createtime" value="">
		</td>
	</tr>
</c:forEach>
function receipt(paybankaccount,payorderid,createtime) {     
	parent.layer.open({
		type : 2,
		skin: "layui-layer-gray",
		title: ["回单查询","font-size:20px;text-align:center;color:#424f62;font-weight:bolder"],
		shade: [0.6,"#767575"],
		maxmin: true,
		scrollbar:false,   
		shift: 2 ,
		area: ["400px", "300px"],
		content : "${ctx}/receipt.do?payorderid=" + payorderid + "&paybankaccount=" + paybankaccount +"&createtime=" + createtime
	});
}

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明在jsp页面遍历时,用JS取值问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)