0
在更新cakephp输入时,基于同一个cakephp表单中的其他输入,我有很多困难。这里是代码形式:使用javascript更新cakephp表单输入
echo $this->Form->input('UnitPrice',['id'=>'unitPrice', 'type' => 'number']);
echo $this->Form->input('SalePercent', ['id'=>'salePercent', 'type'=>'number']);
echo $this->Form->input('SalePrice', ['id'=>'salePrice', 'readonly'=>'readonly']);
这里是JScript:
$('#salePercent').on('input', function() {
calculate();
});
function calculate(){
var sPercent = parseInt($('#salePercent').val());
var sPrice="";
if(isNaN(uPrice) || isNaN(sPercent)){
sPrice=" ";
}else{
sPrice = (uPrice*(1-(sPercent/100))).toFixed(2);
}
$('#salePrice').val(sPrice);
}
什么即时通讯寻求实现是有根据的“单价”,“SalePrice”更新和“SalePrice”进入。用我上面的当前代码,这没有发生。我没有得到cakephp表单字段“SalePrice”的回应。这甚至有可能吗?
这里是我怎么想它的工作
我真的对不起,如果这是一个新手的问题一个jsfiddle,我是新来的JavaScript。
亲切的问候
你有什么确切的问题?尽量准确。更精确的问题会带来更好的,有用的答案。 – Pete
对不起。我遇到的问题是表单字段salePrice没有更新。用我的jsFiddle,salePrice输入salePrice后更新。但是我没有从我的Cake表单得到任何回应。 – user2392337