Ciao,
ho 3 select concatenate(non sequenziali).
ho cercato di creare 3 observers in modo da cambiare dinamicamente il contenuto delle select in questo modo:
Codice PHP:
Event.observe(document.getElementById(this.searchItem1),'change',this.updateSearchResults1.bindAsEventListener(this));
Event.observe(document.getElementById(this.searchItem2),'change',this.updateSearchResults2.bindAsEventListener(this));
Event.observe(document.getElementById(this.searchItem3),'change',this.updateSearchResults3.bindAsEventListener(this));
dove:
Codice PHP:
updateSearchResults1: function() {
//only make the request if we're not in the middle of
searching
if(Ajax.activeRequestCount == 0) {
var pars ='select1='+ $F('select1')+'&select2='+ $F('select2')
+'&select3='+ $F('select3');
//var pars = this.nomeParametro + '=' + $F(this.searchItem);
pars+= '&tmp='+Math.random();
var url2 ="select2.php";
var url3 ="select3.php";
//show the activity indicator
$(this.activityItem).style.display = '';
//make the ajax request
var myAjax = new Ajax.Request(url2,{method:
'post',parameters:
pars,onComplete: this.handleSearch2.bind(this)});
var myAjax1 = new Ajax.Request(url3,{method: 'post',parameters:
pars,onComplete: this.handleSearch3.bind(this)});
}
},
Codice PHP:
handleSearch2: function(originalRequest) {
//parse the results
$(this.resultsItem2).innerHTML =
originalRequest.responseText;
//hide the activity indicator
$(this.activityItem).style.display = 'none';
},
handleSearch3: function(originalRequest) {
//parse the results
$(this.resultsItem3).innerHTML =
originalRequest.responseText;
//hide the activity indicator
$(this.activityItem).style.display = 'none';
}
quando cambio il valore di una delle 3 select il codice della funzione updateSearchResultsX viene eseguito e funziona, ogni qualvolta io cabio il risultato della setesa select.
Quando provo a cabiare il valore di una delle altre 2 select (dopo averne già cambiata 1) l'observer non sembra funzionare, infatti non succede nulla..
qualcuno riesce ad aiutarmi???