Chained Select Box

Chained Select Box

gpdizongpdizon Posts: 1Questions: 1Answers: 0
edited April 2015 in Free community support

I want to put a chained <select></select> box in datatables' editor popup window, but I always failed to display my desired result.
Yet I got the data from my 3 database tables, but it shouldn't work like that.
It should be like this:

selecting REGION from Region with a list of all regions.,
regions.RID matches provinces.RID, displaying PROVINCE with the selected REGION'S ID.
selecting PROVINCE from Province with a list of provinces within the selected region before.
provinces.PID matches districts.PID, displaying DISTRICTS with the selected PROVINCE'S ID.
selecting DISTRICTS from Districts with a list of districts within the selected province before.

Here's my code'

<?php

Editor::inst( $db, 'accounts' )
->fields(
Field::inst( 'accounts.FN' ),
Field::inst( 'accounts.MN' ),
Field::inst( 'accounts.LN' ),
Field::inst( 'accounts.EN' ),
Field::inst( 'accounts.AGE' ),
Field::inst( 'accounts.BD' ),
Field::inst( 'accounts.GENDER' ),
Field::inst( 'accounts.PHONE' ),
Field::inst( 'accounts.EMAIL' ),
Field::inst( 'accounts.POSITION' ),
Field::inst( 'accounts.AFFILIATION' ),
Field::inst( 'accounts.OADDRESS' ),
Field::inst( 'accounts.HADDRESS' ),
Field::inst( 'accounts.BARANGGAY' ),
Field::inst( 'accounts.REGION' )
->options('regions', 'RID', 'REGION'),
Field::inst( 'accounts.DIVISION' )
->options('provinces', 'PID', 'PROVINCE'),
Field::inst( 'accounts.DISTRICT' )
->options('districts', 'DID', 'DISTRICT')
)
->leftJoin( 'regions', 'regions.RID', '=', 'accounts.REGION')
->leftJoin( 'provinces', 'provinces.PID', '=', 'accounts.DIVISION')
->leftJoin( 'districts', 'districts.DID', '=', 'accounts.DISTRICT')
->process( $_POST )
->json();

This discussion has been closed.