Tutorial: Using Ajax Button

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:

In the quantity we put the fields to Create
We put the type of field, the name and the label of the Field.

4. In the application menu, click the “Buttons >> New button” item and select the type “Ajax “.


We can customize the Button in this way

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“.

This time we will position our button created in the lower toolbar and centered

7. Click the Run button on the toolbar.

To see more examples created with Scriptcase, go to: Examples: Complete systems and applications with Scriptcase

Tutorials in the same category

Tutorial: Multi Step Form

In this sample we’ll see how to create a multi step form. The form will be more nice, intuitive an...

Responsive login form 3

To learn how to use the templates available within the ScriptCase in the security module, follo...

Responsive login form 2

To learn how to use the templates available within the ScriptCase in the security module, follo...

Responsive login form

To learn how to use the templates available within the ScriptCase in the security module, follo...

Comment this post