This topic is locked

Popup Confirmation Before Add

4/18/2013 4:52:40 AM
PHPRunner General questions
G
GunnySJB author

I'm trying to get a popup message when a user go's over budget.

He can then decide that he will do the expense or not.
I've tried it with this code in the 'BEFORE RECORD ADDED'
if ($values['BedragNegatief'] > $_SESSION['Totaal'])

{

echo "<script>confirm('You are spending more than u have, do you want to continue ?')</script>";

$message="over budget";

return false;

}
But i don't know how to accept the OK or CANCEL.

Now i only can cancel the save.

Admin 4/18/2013

BeforeAdd happens on the web server meaning you cannot use Javascript interaction there. Luckily there is much easier way to achieve this:

http://xlinesoft.com/phprunner/docs/how_to_ask_for_confirmation_before_saving_record.htm

G
GunnySJB author 4/19/2013

Hello
Yes i've tried this but nothing happened.
My code in the javascript onload from the add page :
if (proxy.uitgaven > proxy.Totaal)

{

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj)

{

if (confirm('U bent over budget, bent u zeker dat u deze boeking wilt doen'))

return true;

else

return false;

});

}
And i assigned the values in the before.display page
$pageObject->setProxyValue("totaal", $_SESSION["Totaal"]);

$pageObject->setProxyValue("uitgaven", $_SESSION["Uitgaven"]);
Can you see anything wrong.
Nothing happens at all ?

Admin 4/19/2013

Variables in Javascript are case-sensitive. Totaal and totaal are two different variables.
In general, you need to make sure your code works. Make sure no Javascript errors happening there. This article can help you troubleshoot Javascript code:

http://xlinesoft.com/blog/2012/05/22/how-to-troubleshoot-javascript-errors/
Another advice - before adding new code make sure that the sample code from the manual works. Once you got it working you can start adding your own logic.

G
GunnySJB author 4/23/2013

Ok i corrected it. But the problem that keeps existing is that the "ask for confirmation" not worked.
I could only add records inline, so changed that for testing and now it works.
But i need to ask for the confirmation with the inline add. Is this possible ?

Admin 4/23/2013

Without seeing the whole application it is very little we can do.
If you have a valid support contract post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.