This topic is locked

calculate field value with button

5/18/2017 7:51:26 AM
PHPRunner General questions
ffrinai author

Phprunner enterprise 9.7 build 28765

Hi,

i'd like to calculate a field in add/edit page with button.

i create a button in ADD page and insert this code:
onServer:
global $dal;

$record = $button->getCurrentRecord();
if (STRVAL($record['veas1'])==0 and STRVAL($record['veao'])==0 and $record['verfm'] == "NO" and $record['dtirif']<>'' and $record['dtfrif']<>'') {
$sql = "select sum(emas1t) as emesseasl, sum(inas1p) as pos,sum(veas1) as versatoasl,sum(emaot) as emesseao,sum(veao) as versatoao from movimenti where dtmov >= '".$record['dtirif']."' and dtmov <= '".$record['dtfrif']."'";

$sql=$sql." and idcassa='".$record['idcassa']."' and idtipou='".$record['idtipou']."'";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

$differenza= $data["emesseasl"] - $data["pos"] ;

$daversareasl=$data["emesseasl"] - $data["pos"] - $data["versatoasl"] ;
$result["veas"] = $daversareasl;

}
Which code, and where, I need to enter, to set and see the field $value["veas"] in the ADD/EDIT form before to click save button?
thanks

Fabio