通過上一篇的JAVA操做後,全部必要的屬性已加進新的 jsonobject 中, 而且是字符串,css
利用 JS eval() 將 該字符串轉爲 JS 對象html
var receiptPolicyListArray = eval('<%=receiptPolicyList%>'); //注意: alert(eval("{}"); -> return undefined // alert(eval("({})"); -> return object[Object]
初始化微回執頁面json
//找到選擇的微回執 var receiptPolicy; for ( p in receiptPolicyListArray) { if(receiptPolicyListArray[p].policyNo=='<%=policyNo%>'){ receiptPolicy=receiptPolicyListArray[p]; break; } } //alert(receiptPolicyListArray[p].applyName + "\n" + receiptPolicyListArray[p].insName + "\n" + rece//iptPolicyListArray[p].policyNo); //初始化頁面 showReceiptPage(receiptPolicy); //初始化函數 function showReceiptPage(receiptPolicy){ //當已經籤的回執receiptPolicyNum不等於 $("#yes").src = "<%=request.getContextPath()%>/globaleNew/images/service/checkboxred.png"; $("#no").src= "<%=request.getContextPath()%>/globaleNew/images/service/checkboxred.png"; if(receiptPolicyNum!=receiptPolicyListArray.length){ $("#tipsYanZheng").css({"display": "none"}); $("#yanzhengCodeId").css({"display": "none"}); } if(receiptPolicy.templateFlag=="A"){ $("#policyNoId").html(receiptPolicy.policyNo); $("#policyNoId2").html(receiptPolicy.policyNo); $("#applyNameId").html(receiptPolicy.applyName); $("#insNameId").html(receiptPolicy.insName); $("#tsalesdscId").html(receiptPolicy.tsalesdsc); $("#agntnameId").html(receiptPolicy.agntname); $("#agntnumId").html(receiptPolicy.agntnum); $("#applyNameId2").html(receiptPolicy.applyName); $("#phoneNumId").html(receiptPolicy.phoneNum); $("#yinxiaoId").html("營銷服務部:"); $("#yinxiaoyuanId").html("營銷員:"); $("#yinxiaoyuanNumId").html("營銷員號碼:"); var thankHtmlA = "<p> 很是感謝您...</p>"; thankHtmlA +="<p> 您的...</p>"; thankHtmlA +="<p> 特別提示您,在您收到...</p>"; $("#thankInfo").html(thankHtmlA); var noteHtmlA = "<p>本人已收到...</p>"; $("#knowInfo").html(noteHtmlA); } if(receiptPolicy.templateFlag=="B"){ ... } ... }