This example demonstrates the use of the AJAX button in a control form.
Creating a Control Form
1. Create a new control type application.
2. In the application menu, open the “Fields” folder and then click on the “New Field” item.
3. We are going to create three fields. Enter the name and label fields according to the images below:
4. In the application menu, click the “Buttons >> New button” item and select the type “Ajax “.
5. We will use the following code on the button .
Button
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
$browser = 'Internet explorer';
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE)
$browser = 'Mozilla Firefox';
elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE)
$browser = 'Google Chrome';
if($lang == "es")
{
{info} = "Hoy es ".date('d-m-Y').", ".date('H:i:s')." y su IP es: ".$ip;
}
else
{
{info} = "Today is ".date('d-m-Y').", ".date('H:i:s')." and your IP is: ".$ip;
}
{browser} = $browser;
{language} = strtoupper($lang);
6. Now we must configure the “Toolbar“.
7. Click the Run button on the toolbar.
To see more examples created with Scriptcase, go to: Examples: Complete systems and applications with Scriptcase
Comment this post