Hi
i have done a form like demo-autocompleter, but in event on countries_list i read data from db. It works correctly.
In my example I have 2 table: comune (idComune,nomeComune,idProvincia) and provincia(idProvincia,nomeProvincia)
i have a form with 2 text box.
1) Comune--> autocomplete
2) Provincia --> readonly which show the nomeProvincia of the relevant comune
In events i have:
on Load:
Autocompleter with ajax form event that trigger to event: ajax_comuni. This event have :
1)db read event, that have as Fields the field nomeComune
2) a custom code with:
In my table comune i have to retrieve the field idProvincia to get , from table "provincia", the nameProvincia. Then i have to put this value in textBox Provincia
Suggest:
1) i have to put idProvincia in event DB read in Fields o in conditions (<?php return array( 'idProvincia' => $form->data['provincia'] ); ?> )?
2) if yes, after getting idProvincia, i have to set another DB read after custom code to get nomeProvincia by idProvincia and then put it in Textbox Provincia?
Thanks for your support
Regards
Daniele
i have done a form like demo-autocompleter, but in event on countries_list i read data from db. It works correctly.
In my example I have 2 table: comune (idComune,nomeComune,idProvincia) and provincia(idProvincia,nomeProvincia)
i have a form with 2 text box.
1) Comune--> autocomplete
2) Provincia --> readonly which show the nomeProvincia of the relevant comune
In events i have:
on Load:
Autocompleter with ajax form event that trigger to event: ajax_comuni. This event have :
1)db read event, that have as Fields the field nomeComune
2) a custom code with:
<?php
$countries = array();
if ( !$form->data['Data'] || count($form->data['Data']) < 1 ) {
// no result was found
$countries[] = 'Nessun comune in lista';
} else {
foreach ( $form->data['Data'] as $d ) {
$countries[$d['nomeComune']] = $d['nomeComune'];
}
}
foreach($countries as $country){
if(!empty($form->data['tag']) AND stripos($country, $form->data['tag']) === false){
continue;
}
$json[] = array('id' => $country, 'text' => $country);
}
echo json_encode($json);
?>
In my table comune i have to retrieve the field idProvincia to get , from table "provincia", the nameProvincia. Then i have to put this value in textBox Provincia
Suggest:
1) i have to put idProvincia in event DB read in Fields o in conditions (<?php return array( 'idProvincia' => $form->data['provincia'] ); ?> )?
2) if yes, after getting idProvincia, i have to set another DB read after custom code to get nomeProvincia by idProvincia and then put it in Textbox Provincia?
Thanks for your support
Regards
Daniele