我的表单如下:HTML
<form class="form-horizontal demo-form">
<fieldset>
<div class="form-group">
<div class="col-md-5">
<input type="text" required="" class="form-control input-md" placeholder="From Range" data-field="l1_price.from" id="from">
<input type="text" required="" class="form-control input-md" placeholder="To Range" data-field="l1_price.to" id="to">
<input type="text" required="" class="form-control input-md" placeholder="Price" data-field="l1_price.price" id="price">
</div>
<div class="col-md-5">
<input type="text" required="" class="form-control input-md" placeholder="From Range" data-field="l2_price.from" id="from">
<input type="text" required="" class="form-control input-md" placeholder="To Range" data-field="l2_price.to" id="to">
<input type="text" required="" class="form-control input-md" placeholder="Price" data-field="l2_price.price" id="price">
</div>
<div class="col-md-5">
<input type="text" required="" class="form-control input-md" placeholder="From Range" data-field="l3_price.from" id="from">
<input type="text" required="" class="form-control input-md" placeholder="To Range" data-field="l3_price.to" id="to">
<input type="text" required="" class="form-control input-md" placeholder="Price" data-field="l3_price.price" id="price">
</div>
</div>
<div class="form-group">
<label for="submit" class="col-md-4 control-label"></label>
<div class="col-md-5">
<button class="btn btn-success" id="submit">Submit</button>
</div>
</div>
</fieldset>
</form>
我的Java脚本代码:
$("form")
.serializer()
.on("serializer:data", function (e, formData) {
alert(JSON.stringify(formData));
});
Json对象
"range":{
"l1_price":
{"from":"0", "to":"260k", "price": "Rs 2"},
"l2_price":
{"from":"260k", "to":"500k", "price": "Rs 4"},
"l3_price":
{"from":"500k", "to":"1MM", "price": "Rs 7"},
"l4_price":
{"from":"1MM", "to":"2MM", "price": "Rs 3"}
}
但实际的Json对象
{
"range":{
"l1_price":
{"from":"0", "to":"260k", "price": "Rs 2"},
"l2_price":
{"from":"260k", "to":"500k", "price": "Rs 4"},
"l3_price":
{"from":"500k", "to":"1MM", "price": "Rs 7"},
"l4_price":
{"from":"1MM", "to":"2MM", "price": "Rs 3"}
},
"rates" : [".02",".04",".007",".003",".002"],
"thresholds": [26e4,5e5,1e6,2e6,3e6]
}
问题对于速率和阈值,我如何从表格或上面的json范围数组中获得动态