This topic is locked
[SOLVED]

 Strange Button behavior

12/3/2019 11:11:10 AM
PHPRunner General questions
M
Mark Kramer author

I have a button that fills in "clock out data" ie time and date and then saves the record. The issue is that with each record the save button number changes...
var d = new Date();

var ctrlDate = Runner.getControl(pageid,'TimeOut');

ctrlDate.setValue(d);
var CD = Runner.getControl(pageid,'TimeIn');

var DO = new Date(CD.getValue());

var DOP = Date.parse(DO)

var dp = Date.parse(d)

var TT =Runner.getControl(pageid,'Totaltime');

var cl = Runner.getControl(pageid,'closed');

// get total seconds between the times

var delta = Math.abs(dp - DOP) / 1000;
// calculate (and subtract) whole days

var days = Math.floor(delta / 86400);

delta -= days 86400;
// calculate (and subtract) whole hours

var hours = Math.floor(delta / 3600) % 24;

delta -= hours
3600;
// calculate (and subtract) whole minutes

var minutes = Math.floor(delta / 60) % 60;

delta -= minutes * 60;
// what's left is seconds

var seconds = delta % 60;
tto =(days)+" day(s) "+(hours)+" hr(s) "+(minutes)+" min "+(seconds)+" sec "
TT.setValue(tto);

cl.setValue(1);
$("#saveButton12").click(); //emulate save button
return false;
When I right click on the "save button" and inspect element, It is differnt number for each record . So if this is normal, how do we emulate the $("#saveButton12").click() in the button code when it changes with each record? I can't find any corresponding record id for the $("#saveButton " ) number..
Thank you.

Sergey Kornilov admin 12/3/2019

You need to use the recommended API for this task. Button IDs are meant to change from one record to another so we know which one was clicked.
Select that button in Page Designer and click question sign next to "item id".
Now check this, the last code example:

https://xlinesoft.com/phprunner/docs/getitembutton(itemid_recordid).htm
This should be sufficient.

M
Mark Kramer author 12/3/2019



You need to use the recommended API for this task. Button IDs are meant to change from one record to another so we know which one was clicked.
Select that button in Page Designer and click question sign next to "item id".
Now check this, the last code example:

https://xlinesoft.com/phprunner/docs/getitembutton(itemid_recordid).htm
This should be sufficient.


That did the trick!

Thank you