Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
multiple Event.observe [prototype]

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
airude
New one
New one


Joined: 26 Nov 2007
Posts: 1

PostPosted: Mon Nov 26, 2007 11:01 am    Post subject: multiple Event.observe [prototype] Reply with quote

Hi,
I have 3 chained select (not sequential) and I tried to create 3
observers in order to change select contents
dynamically in this way:

Code:

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));


Code:

        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)});
    }
        },


Code:

        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';
        }


When I change the value of 1 of the 3 select the code in the function
updateSearchResultsX is executed and it continues working everytime i
change the value of the same select.

When I try to change 1 of the other select values(after the first
change) the observer doesn't seem to work infact nothing happens.

Can you please help me????
Back to top
View user's profile Send private message
Jesdisciple
Frequent Poster
Frequent Poster


Joined: 20 Oct 2007
Posts: 36
Location: Tejas

PostPosted: Fri Dec 07, 2007 7:14 pm    Post subject: Reply with quote

Sorry I've taken some 10 days to respond. Could you post a complete page, please (preferably with the troublesome feature isolated)? I have no body or select elements to work with, and this in your functions (after being reformatted as standalone) refers to the Window object, rather than whatever it should refer to.
_________________
In ALL things, strive for ><>,
Chris
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert