The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

esvehla (2) [Avatar] Offline
#1
I am new to Prototype and Scriptaculous, your book has been a huge help! Thanks so much for all your hard work, the book is worth every penny and more. smilie

Here is my problem. I want to pass multiple parameters to my data servlet, one parameter represents what the user has typed in the text field, while the other parameter is intended to limit the database retrieval to employees that are in a specific role thus allowing a smaller set of employees to be retrieved to support the data displayed by the Autocompleter object.

What is the best way to pass the multiple parameters to the Autocompleter? Should I add an onkeyup event handler to my text field that in turn calls a function which builds the parameter string that consists of what has been typed as well as the employee type? Will this cause a needless creation of additional Autocompleter objects since this function will be invoked on each onkeyup event?

I reviewed your lab-autocompleter-ajax.jsp but noticed you use an onSubmit event handler to invoke a function which in turn builds the parameter string which is passed to the creation of the Autocompleter.

Thanks in advance!

Ernie
bear.bibeault (675) [Avatar] Offline
#2
Re: Passing multiple parameters to Autocompleter
Hi Ernie, I'm glad to hear that you are finding the book helpful.

With regards to your question, can you not set the "limiting" parameter as part of the options when you orginally create the auto-completer?

The Lab re-creates the auto-completer each time because of the nature of that "lab page" -- you're right, that's not something you want to do in real usage.

bear
esvehla (2) [Avatar] Offline
#3
Re: Passing multiple parameters to Autocompleter
Thanks Bear for the prompt reply. I was able to answer my own question. I had overlooked the fact that when the server side call is made that a parameter with the name 'value' will be included in the server side call which represents what the user has typed in the text field.

Since I know what employee type is associated with what text field I can add a static request parameter to the server url when I create the Autocompleter object.

Thanks again for your help.

Ernie
bear.bibeault (675) [Avatar] Offline
#4
Re: Passing multiple parameters to Autocompleter
No prob! Check back in if you have further questions.