This topic is locked

Prompt when adding record

7/1/2018 9:15:16 AM
PHPRunner General questions
B
beishmc author

I need to create if statement in event "before record added" when user confirm to continue with adding record or else quit adding and return back.
Something like this:

http://asprunner.com/forums/topic/12879-popup-prompt/
echo "<script>if(confirm('are you sure?')){window.location.href='req_header_list.php?a=return'}else{window.location.href='journal_header_list.php?a=return'}</script>";

exit();

B
beishmc author 7/3/2018



Check this:

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


Dear Sergey Kornilov i was aware of this javascript code but i need to validate some result before saving record.
I have this part of code in before add:
$t = ($values["final_state"] - $values["initial_state"]);

....

elseif ($t > "1000") {

echo "<script>alert('Are you sure the vehicle has exceeded trip of 1000km?')</script>";

$message = "Are you sure the vehicle has exceeded trip of 1000km?";

....
What i need is that user confirm that it is sure that vehicle has exceeded road trip of more than 1000km to continue adding record and if user click cancel that it returns to list page.

admin 7/3/2018

It won't work this way. You cannot use Javascript in server side event like BeforeAdd. You need to perform all calculations in Javascript event beforeSave.

F
fabiofurlan 7/11/2018

Ok but how to do it when I need to get data informed by the user in the page add and do select and then present question to user to proceed or not with the recording?



It won't work this way. You cannot use Javascript in server side event like BeforeAdd. You need to perform all calculations in Javascript event beforeSave.