简体   繁体   English

在 visualforce 页面中使用 javascript 计算表行中的总值?

[英]Calculate total value in a table row with javascript in visualforce page?

i have a table with 3 column in visualforce page there is one input value and others are output value.我在 visualforce 页面中有一个包含 3 列的表格,其中有一个输入值,其他值是 output。 When input value is changes, input value and second column value must be multiplied and the third column must show the result for per row.当输入值发生变化时,输入值和第二列值必须相乘,第三列必须显示每行的结果。 in table i'm using apex:repeat and, tags so how can i do this?在表中,我正在使用 apex:repeat 和标签,所以我该怎么做? thanks.谢谢。

i have tried add js method to vf page with parameter and call this method with 'this' attribute in tag like onchange="calc(this)" but did not work.我已经尝试使用参数将 js 方法添加到 vf 页面,并在 onchange="calc(this)" 之类的标签中使用 'this' 属性调用此方法,但没有成功。

i changed my code like this and it works.我像这样更改了我的代码并且它有效。

vf page: vf 页面:

<apex:input id="qua" onchange="calc(this)"/>

js code: js代码:

function calc(p){
    var qua = p.value;
    var row = p.parentNode.parentNode;
    var pack = row.cells[6].innerHTML;        
    row.cells[7].innerHTML = qua * pack;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM