PDA

View Full Version : Combobox with external MySql / Json - choose field correlated



botola59
19 Nov 2010, 12:45 AM
hello, sorry but I'm newer. I created a combobox script using external DataBase MySql trasformed in Json.
In script I select two fields: seda_cod and conc_descr.

The script works correctly but I want a different result as follow described.

The list show the conc_descr content but when the user choose a record the script must use the corrispondent seda_cod field code content (not conc_descr field content).
Is possible it?

script html:


Ext.onReady(function(){
var store = new Ext.data.JsonStore({
url: 'ajax_SQL_ambiti.php',
root: 'result',
fields: ['seda_cod', 'conc_descr']
});
store.load();

var combo = new Ext.form.ComboBox({
store: store,
displayField:'conc_descr',
typeAhead: true,
mode: 'local',
forceSelection:true,
triggerAction: 'all',
emptyText:'Seleziona Ambito...',
selectOnFocus:true,
applyTo: 'localstates_1',
});
});
code PHP 'ajax_SQL_ambiti.php' :


.....connection....

$query_rst_schede = "
SELECT conc_descr, seda_cod
FROM socconc
order by conc_descr
";

$res=mysqli_query($link, $query_rst_schede) or die("Errore Ambito");
while($inf=mysqli_fetch_array($res)){
$seda_cod = $inf["seda_cod"];
$conc_descr = $inf["conc_descr"];
$result[] = array('seda_cod'=>$seda_cod, 'conc_descr'=>$conc_descr);
}
$o = array('result'=>$result);
echo json_encode($o);
thanks advanced

botola59
21 Nov 2010, 11:56 PM
Hello! Some expert can help me?

Condor
22 Nov 2010, 1:06 AM
valueField:'seda_cod',
hiddenName:'<name-of-field>'

botola59
22 Nov 2010, 9:15 AM
Thanks a lot Condor.