JS用JSON传递多个控件
页面:
onchange='resetCtrl([{"id":"hidVId"}])'
JS:
function resetCtrl(refList) {
for (var i = 0; i < refList.length; i++) {
$("#" + refList[i].id).val("");
}
}
JS:
function setCtrls(refList) {
for (var i = 0; i < refList.length; i++) {
$("#" + refList[i].id).val(refList[i].value);
}
}
var ctrlsData = [
{ id: "txtVWeight", value: data.Weight },
{ id: "txtVBrand", value: data.VBrand },
{ id: "hidVC", value: data.TCId },
{ id: "txtVC", value: data.Name },
{ id: "txtVRemarks", value: data.Remarks }
];
setCtrls(ctrlsData);