ok ragazzi..ci sono vicino però non riesco a capire perchè il secondo combo viene aggiornato con un valore null.
Posto i codici della chiamata ajax e del plugin ajax utilizzato..
Chiamata :
Modulo ajax :codice:var cid = this.getValue(); var table = 'Campi'; var key = 'Nomecampo'; var label = 'Nomecampo'; var foreignkey = 'Tipocampo'; var dropdown = 'Registrazione___Campo'; var url = 'index2.php?option=com_fabrik&no_html=1&task=userPluginAjax&method=getFields'; url += '&table=' + table; url += '&val='+cid; url += '&key='+key; url += '&label='+label; url += '&foreignkey='+foreignkey; new Ajax(url, { method: 'get', update: $(dropdown) } ).request();
codice:/* MOS Intruder Alerts */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); class userAjax { function getFields(){ global $database; //get all the variables passed in by the ajax objects url $table = mosGetParam($_REQUEST, 'table'); $key = mosGetParam($_REQUEST, 'key', 'id'); $label = mosGetParam($_REQUEST, 'label', 'label'); $foreignKey = mosGetParam($_REQUEST, 'foreignkey', 'country_id'); $val = mosGetParam($_REQUEST, 'val', '1'); //run a query on the database to get the matching fields $sql = "SELECT $key AS value, $label AS label FROM $table WHERE $foreignKey = '$val'"; $database->setQuery($sql); $rows = $database->loadObjectList(); //write the results of the query back to the browser - the javascript code will then assign //the text to the second drop down foreach($rows as $row){ echo "<option value=\"$row->value\">$row->label</option>"; } } }
Spero in una vostra risposta... cè qualcosa che non va secondo voi nel codice?

Rispondi quotando