JQuery中JSON字符串的属性有子元素读取

</pre><pre name="code" class="javascript">var dataJson={
    "BankName": {
        "value": "",
        "description": "银行名称",
        "type": "int",
        "sort": "1"
    },
    "DeductPrice": {
        "value": "",
        "description": "立减金额",
        "type": "float",
        "sort": "2",
        "child": 
            {
                "StartDeductRange": {
                    "value": "123",
                    "description": "立减开始范围"
                },
                "EndDeductRange": {
                    "value": "123.1",
                    "description": "立减结束范围"
                },
                "DeductRangePrice": {
                    "value": "121",
                    "description": "立减范围金额"
                }
            }
    },
    "PlatForm": {
        "value": "",
        "description": "预订平台",
        "type": "float",
        "sort": "3"
    }
};
for (var json in dataJson) {
	if (eval("dataJson." + json + ".child")) {
                        startDeductRange = " value='" + eval("dataJson." + json + ".child")[item].StartDeductRange.value + "'";
                        endDeductRange = " value='" + eval("dataJson." + json + ".child")[item].EndDeductRange.value + "'";
                        deductRangePrice = " value='" + eval("dataJson." + json + ".child")[item].DeductRangePrice.value + "'";
                        strController += "<tr id='tr" + intIndex + "'>"
                                                + "<td>开始范围:<input style=' width:50px'; type='text'"
                                                + startDeductRange + " οnkeyup='inputFloat(this);' />"
                                                + "</td><td>结束范围:<input style=' width:50px;' type='text' "
                                                + endDeductRange + " οnkeyup='inputFloat(this);' />"
                                                + "</td><td>立减金额:<input style=' width:50px;' type='text' "
                                                + deductRangePrice + " οnkeyup='inputFloat(this);' />";
                        strController += "</td><td><a id='deleteLink1' οnclick='deleteTr(tr" + intIndex + ");'>删除</a>   <a id='addLink" + intIndex + "' οnclick='addTr(this);' style='display:none;'>新增</a></td>"
                                     + "</tr>";
                        intIndex++;
                    }
}

</pre><pre code_snippet_id="268573" snippet_file_name="blog_20140401_1_2551640" name="code" class="javascript">

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值