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