Refreshing a field when someone selects a field or another field (ajax onchange)

Hello!

I’m creating a form in which the user has 3 select fields. One for “customer”, one for “contact” and one for “person”. I want the “customer” and “contact” flield to refresh the “person” field. My problem is that the form only refreshes the “person” field when the user has selected something in the “customer” and “contact” field. I want the form to refresh the “person” field when the user selects only “customer” or “contact”. I tried with this SELECT (on “person” field):

SELECT id_numero, name, id_customer, id_contact
FROM person
WHERE id_customer = ‘{id_customer}’ OR id_contact = ‘{id_contact}’
ORDER BY name

The problem is that only when the form can execute all the SELECT sentence (it is, when it has a value for ‘id_customer’ and a value for ‘id_contact’ it refreshes the person field. I want the form to refresh the person field when the user selects just ‘id_customer’ or ‘id_contact’ alone.

Any tips?

In fact, you want to refresh the select values on the person field when the user changes customer or contact? Are the fields on the form of type select? Then it’s pretty easy. If you scroll down on the customer field you will find a ajax event checkbox which allows you to change the content of some other field when changed. This ‘other’ field needs to be of type select. As soon as you check the box you get a small window showing you the fields to be refreshed. Select the one you need ‘click on select’ so that a start will be printed before the field to show that it’s selected. If your select on the personfield is correct it will be refreshed as soon as the user selects a customer. Same protocol for contact. To avoid the first value in the select use the ‘use title’ property. Enter ‘select…’ as value here. The the pulldown will initially filled with ‘select…’.
Hope this is what you’re looking for…

Hi! Thanks for your reply.

I have problems in the “person” field. The person field only refreshes once the ‘customer’ and ‘contact’ field have some value. As I said, it seems that the ‘person’ fields waits to be refreshed until it can execute all the SQL sentence:

SELECT id_numero, name, id_customer, id_contact
FROM person
WHERE id_customer = ‘{id_customer}’ OR id_contact = ‘{id_contact}’
ORDER BY name