Back
<?php
// highlight file option..
if( !empty($_GET['source']) ) {
echo
"<a href='linkselectfields2.php'>Back</a>\n".
"<br />\n".
"<hr size='1' />\n";
highlight_file( __FILE__ );
exit;
}
// include formhandler
include('../includes/FH3/class.FormHandler.php');
$filter = $_POST['filter'];
// switch which field is changed
switch( $_POST['field'] ) {
// select the right town
case 'town':
// is a country selected?
if( $filter != 0 ) {
// here you can select the items which
// should be loaded in the "town" field
// You can use $filter to select
// the town's which are linked tho that specific country
// After selecting the town's, put them into an array and
// pass them to the setDynamicOptions method like below
if( $filter == 1 ) {
$towns = array(
0 => '-- Select --',
1 => 'Town 1a',
2 => 'Town 1b'
);
} else {
$towns = array(
0 => '-- Select --',
3 => 'Town 2a',
4 => 'Town 2b'
);
}
FormHandler::setDynamicOptions( $towns );
}
break;
case 'street':
switch( $filter ) {
// town 1a is selected
case 1:
$streets = array(
'street 1a I'=>'street 1a I',
'street 1a II'=>'street 1a II'
);
break;
// town 1b is selected
case 2:
$streets = array(
'street 1b I'=>'street 1b I',
'street 1b II'=>'street 1b II'
);
break;
// town 2a is selected
case 3:
$streets = array(
'street 2a I'=>'street 2a I',
'street 2b II'=>'street 2b II'
);
break;
// town 2b is selected
case 4:
$streets = array(
'street 2b I'=>'street 2b I',
'street 2b II'=>'street 2b II'
);
break;
// when no town is selected...
default:
$streets = array();
break;
}
FormHandler::setDynamicOptions( $streets );
break;
default:
FormHandler::setDynamicOptions(
array(
'Given filter: '.$filter,
'Load options of field: '.$_POST['field']
)
);
break;
}
?>