Using ajax: onChange events

Using ajax: onChange events

In this article we will see how the onChange event works, available in Scriptcase. It is triggered when the object, which makes use of it, has its value changed.

Down below is an example of using this event. We will use an order items form, we will use ajax on the form to capture the unit price of the product and calculate the total price based on the quantity of products desired.

1. First, let's configure the product field to display the product name at the location of the ID.

We must access the application settings, and select the field in question (productid).


 

 

2. Next, we must change the type of the field to an auto-complete number, as it is of the type number.



3. Finally, we must configure the display lookup, using the products table to find the product names.



4. Next, we will create an ajax event (onChange) in the productid field, to find the unit price in the table when informing the product name.


 

5. We will use the sc_lookup macro (For more information click here) to search for this information in the database.


 

6. Next, we will create another ajax event (onChange), this time in the quantity field, to calculate the total value by informing the desired quantity.



7. Next, we can see the Ajax prcessing .


    • Related Articles

    • Using sc_ajax_refresh()

      -Create a grid -At the Ajax Event -New Ajax Event: -Select the Event onClick and the desired field, and create: -Add the following macro: sc_ajax_refresh (); -When clicking on the record in that field, the page would be reloading Corresponding ...
    • Using Ajax Processing(Refresh)

      In this article we will learn how to use the "Ajax Processing" function available in Scriptcase. As an example, we have a control-type application with two select fields ("state" and "city"), where when we select the state we will use ajax processing ...
    • Using the sc_field_display macro

      To dynamically hide a field in this example, the macro sc_field_display is used, which is responsible for hiding or dynamically displaying a field or several. This macro has scope in the following events: In this example, it will be used within an ...
    • Using friendly URL

      The friendly URL was included from Scriptcase 7, in order to make the URL, of the applications generated by Scriptcase, cleaner and easier to associate them with applications. For example, using friendly URLs the link to a Scriptcase application ...
    • Using Languages in Scriptcase

      In Scriptcase you have the option to standardize the language information quickly and uncomplicated. Using the feature you can change LANGUAGES entire textual structure of the project, since this native messages Scriptcase own name to fields and ...
    • Popular Articles

    • Examples for diagrams

      This tutorial shows how you can import and use the new examples for diagrams released with Scriptpcase V9.2.16.  The applications were created using the components: Jsmind, JKanban e Orgchart.  - Sample 1: Mind Map diagram Click here to  execute the ...
    • Manual Update - Windows

      Before performing any procedure we recommend performing a backup of your projects. To back up Scriptcase: Go to Settings > Administration, in the side menu go to Services > Backup. A file (.ZIP) will be generated with all your projects, save this ...
    • PHP functions necessary for ScriptCase

      In PHP , there are some essential functions for the operation of Scriptcase .  On some servers , these functions are disabled , this makes the Scriptcase not work properly.  If you're using a shared hosting server, you'll need to contact the host ...
    • Oracle Connection - Scriptcase 9 - Linux 64 Bits

      This procedure will only work if you have a Scriptcase manual installation in your server. Installing PHP 7.0 Installing the Scriptcase Manually To connect with Oracle in a Linux System, we must follow these steps below: Step 1 -  Installing these ...
    • Using friendly URL

      The friendly URL was included from Scriptcase 7, in order to make the URL, of the applications generated by Scriptcase, cleaner and easier to associate them with applications. For example, using friendly URLs the link to a Scriptcase application ...