Alert message box after the server side script

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

Alert message box after the server side script

#1

Postby azaleas » Wed Sep 09, 2015 10:50 am

I have an alert message on button's HTML Event Handler. There's also a JS script on On-Click event of the button. How to make the alert box pop up after the script is finished? Or, there's a pop up for mandatory fields. If I don't fill the mandatory field and then click the button, first the alert message of the button pops up, and then the alert message for mandatory field appears. How to change change this appearance? The alert box message should only pop up, once the button is clicked and then the on-click event script is finished.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Wed Sep 09, 2015 1:39 pm

Have you thought about a different user interface - as opposed to the alert popup? The easiest way to notify the user about something is to add a warning message to the page. You do this by adding a statement like the following to the end of your on-click server-side script, and the message is displayed above the button - though you can reposition it anywhere you like. These messages are normally highlighted to catch the user's attention but they disappear when the next event on the page happens, so this is a common technique for just informing the user that an action has been performed e.g. "Your request has been received" etc.

Code: Select all

event.owner.addWarningMessage("Something has happened");
If you are really set on an alert message, then you could do it in a few ways though they all take longer to implement than the suggestion above. Here's one way: remove the script from the on-click server-side event. Instead add some code to the client-side on-click handler which calls the server to execute a function using the client API $eb.executeFunction() method - this is a direct programming call from client-side Javascript to server-side Javascript. This can return information to the client which can then be displayed in an alert message. To implement this you need to move your server-side code to a function which is accessible from the client - add it to a script included in the Client Callable Functions configured in Form Properties > Events. Finally, add "return false" as the last line of your on-click code - this stops the call to the server. These client-server interactions are conceptually quite difficult especially if you're new to Ebase Xi.
0 x


Who is online

Users browsing this forum: No registered users and 4 guests