It sounds like you don't need Ajax.Autocompleter, it is overkill. 
However, looking at it's code I came up with this in a matter of 
minutes. It's not tested but you get the idea I think. If you need any 
more functionality that is included in Autocompleter but not here just 
look at the code (controls.js).

Ajax.Listener = Class.create();
Ajax.Listener.prototype = {
    initialize: function(element,target,page,options){
       this.element = $(element);
       this.target = $(target);
       this.page = page;
       this.options = Object.extend({
          frequency: 1000,
          parameters: '',
          ajaxOptions: {}
       },options || {}
       this.observer = null;
       this.onKeyPressHandler = onKeyPress.bind(this);
       Event.observe(this.element, 'keypress', this.onKeyPressHandler);
    },
    onKeyPress: function(){
       if(this.observer) clearTimeout(this.observer);
       this.observer = setTimeout(this.onObserverEvent.bind(this), 
this.options.frequency*1000);
    },
    onObserverEvent: function(){
       var params = this.element.name+'='+this.element.value;
       if(this.options.parameters) params += '&'+this.options.parameters;
       new Ajax.Updater(this.target, this.page, 
Object.extend(this.options.ajaxOptions,{
          parameters: params
       });
    },
    dispose: function(){
       Event.stopObserving(this.element, 'keypress', 
this.onKeyPressHandler);
    }
}

<textarea id="mytext" name="userText"></textarea>
<div id="myinfoarea"></div>
<script>
new Ajax.Listener('mytext','myinfoarea','mypage.php',{
   parameters: 'extraParam=extraValue'
});
</script>

The POST on server side will be:
'userText' => 'whatever they entered',
'extraParam' => 'extraValue',
'_' => ''

Colin

frank wrote:
> Here it is once again:
>
> Let's say there's a page with a textbox. You enter text into the
> textbox. As soon as you enter the text into the textbox, some
> information pertaining to the text you entered is displayed below the
> textbox. Some database queries might run in the backend which take the
> inputed text as paramters. I want to accomplish this withough having to
> press any buttons. Like I said, Ajax.Updater can perform most of the
> duties listed above, but I could only get Ajax.Autocompleter to send
> the text enter on the fly to a processing script. I do not know how to
> get the two to work together, or even if they are both required so that
> is why I am asking.
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to