我在Js中有一个表单从用户中选择数量,然后从数据库中获取产品价格。令人困惑的部分是如何添加一个字段(总价格),显示两个字段的结果而不显示文本框。我的代码如下:
var sales = App.extend(App.Cmp, {
modelId: 'sales',
httpUrl: './sales',
responseTarget: 'ajax-content',
columnModel: ['name'],
title:'sales',
model: [{
id: 'Product',
label: 'product ',
name: 'prod_Name',
type: 'select',
options: [],
placeholder: 'name of product',
required: 'required'
},{
id: 'Quantity',
label: 'Quantity',
name: 'sale_Quantity',
type: 'text',
placeholder: 'Quantity',
required: 'required'
},{
id: 'Price',
label: 'Total Price',
name: 'sale_Price',
type: 'text',
placeholder: 'total price',
required: 'required'
}],
removeRecord: true
});
(function(){
sales.ajaxRequest.call({
httpMethod : 'GET',
httpUrl : './product',
updateTarget : function(resp) {
var options = [];
console.log(resp);
JSON.parse(resp).forEach(function(el){
options.push({
label: el.Name,
value: el.id
});
});
sales.model[0].options = options;
}
})
})();