[SOLVED]Use AJAX to reload other fields of type Select Bug

I?m trying to use the field feature of reloading other field of type select when a change occurs in this field. The select clause of the field to be reloaded depends on the value of the changed field. The bug is that when the field being changed has no values, the list of values of the field to be reloaded is not reset (emptied). Help please. Is there a form that I can do it manually.
Thank you.

Re: Use AJAX to reload other fields of type Select Bug

Let me suggest that you have 2 fields (field1 and field2).

onchange field1 AJAX feature : please type this -->

//if value of field1 is empty, erase field2 content.
if({field1}==’’)
{
{field2}=’’;
}

Suyono

Re: Use AJAX to reload other fields of type Select Bug

I?m sorry but I didn?t explain the problem very well. This is the way it should be:
I?m trying to use the field feature of reloading other field of type select when a change occurs in this field. The select clause of the field to be reloaded depends on the value of the changed field. The bug is that when the field to be reloaded has no values for that particular value of the field being changed, the list of values of the field to be reloaded is not reset (emptied). Help please. Is there a form that I can do it manually.
Thank you.

By the way assigning a value to a field of type select only set the value to be displayed, but not the entire list. How can I reset the entire list manually?

Re: Use AJAX to reload other fields of type Select Bug

There is a tutorial on this topic.

http://www.scriptcase.net/phpgenerat…rch/grid31.php

If your select loaded is blank, that is because your lookup value statement has error.

Here is an example 1:
Have two fields - Race and Sub-Race
You will need 3 tables, Race table, SubRace table, RaceSubRace table

races table has 2 fields -> idRaces and Race

subraces table has 2 fields -> idSubRaces and SubRace

racesubrace table has 2 fields -> idRaces and idSubRaces

Race field -> 1. set field type as Select
2. set automatic lookup to Race table

SELECT idRaces, Race
                  FROM races
                  ORDER BY Race
             

SubRace field -> 1. set field type as Select
2. set automatic lookup to SubRace table

SELECT idSubRaces, SubRace
                  FROM subraces
                  ORDER BY SubRace
             

Now go back to the Race field -> 1. enable Ajax Processing
2. double-click on field SubRace as the field to be reloaded

Now go back to the SubRace field -> 1. set automatic lookup to


                                 SELECT idSubRace, SubRace
                                 FROM racesubrace
                                 WHERE idRaces = '{Race}'
                                 ORDER BY SubRace
                              

Here is an example 2:
Form have two fields - Race and SubRace
You will need 3 tables, races table, subraces table, racesubrace table

races table has 1 field -> Race

subraces table has 1 field -> SubRace

racesubrace table has 2 fields -> race and subrace

Race field -> 1. set field type as Select
2. set automatic lookup to Race table

SELECT Race
                  FROM races
                  ORDER BY Race
             

SubRace field -> 1. set field type as Select
2. set automatic lookup to SubRace table

SELECT SubRace
                  FROM subraces
                  ORDER BY SubRace
             

Now go back to the Race field -> 1. enable Ajax Processing
2. double-click on field SubRace as the field to be reloaded

Now go back to the SubRace field -> 1. set automatic lookup to


                                 SELECT subrace
                                 FROM racesubrace
                                 WHERE race = '{Race}'
                                 ORDER BY subrace
                              

Make sure that are there tables are populated with some values before testing it.

Re: Use AJAX to reload other fields of type Select Bug

It doesn’t work for me.
This is what I have:
Application Type: Form
Table: Addresses
Fields: AddressID,
LocationID,
Street,
ZipPostcode,
*Location,
*District,
*Province,
*Department
Where Fields with asterisk are calculated fields of type select.

Field 1.
Name: Department
SQL Automatic Lookup: SELECT DepartmentID, Name
FROM Departments
ORDER BY Name
Use AJAX to reload other field: *Province

Field 2.
Name: Province
SQL Automatic Lookup: SELECT ProvinceID, Name
FROM Provinces
WHERE DepartmentID=’{Department} ’
ORDER BY Name

Re: Use AJAX to reload other fields of type Select Bug

As I said it before: When I select a department that has provinces it resets the field provinces correctly, but if the department has no provinces it just ignores the field.

Re: Use AJAX to reload other fields of type Select Bug

i think this case depend on your database schema.
to be clear you should tell us not only table addresses but also department and province.

to automatically fill province field. you have to link table between department and province first then make query based your approach.
use on ajax change on field department to fill province field.

suyono

@Firetouch, your problem you only have 2 tables (Departments & Provinces) instead of 3 tables (Departments, Provinces & Dept_x_Province)

Dept_x_Province table should have 2 fields -> DepartmentID & ProvinceID

Field 1.
Name: Department
SQL Automatic Lookup:


SELECT DepartmentID, Name 
FROM Departments 
ORDER BY Name

Use AJAX to reload other field: *Province

Field 2.
Name: Province
SQL Automatic Lookup:


SELECT ProvinceID, Name 
FROM Dept_x_Province 
WHERE DepartmentID = '{Department} '
ORDER BY Name