Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Dropdown in cascata

  1. #1

    Dropdown in cascata

    Salve ragazzi, qualcuno di voi sà come è possibile con codice javascript personalizzato mettere due dropdownmenu in cascata?

    Io non conosco javascript ma devo far diventare il valore scritto dentro il primo dropdown l'argomento di un filtro query sul secondo dropdown.

    Utilizzo Joomla e un componente di nome Fabrik.

    Questa è la pagina che sto realizzando: http://iboitalia.start-aid.org/index...mid=94&lang=it

    a riguardo dell'argomento ho trovato anche queste discussioni, ma applicando quello che ho trovato non sono riuscito a saltarci fuori.
    http://fabrikar.com/forums/showthread.php?t=6246

  2. #2
    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 :

    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();
    Modulo ajax :
    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?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.