Hi All,
I'm wondering whether someone might be able to help me with an autocomplete form I'm creating.
The CCK node has the following structure
name (text)
age (int)
title (text)
biography (body text)
I am accessing a third party database (via REST API) with the names, titles and ages of a number of people. I want my user to find a person by typing into an autocomplete textbox. However when they select the user I want the age to also be populated with results of the query. So for example if my third party has the following data:
sally, 36
john, 24
david, 33
when the user types sally into the autocomplete textbox then the age field is populated with 36 and all they need to do is fill in the title and biography.
I know how to do this with just one field but wanted to update two at the same time. I have had a good look on google and in the forums but can't find any answers so through I'd send in my own post.
Thanks very much to anyone who might be able to point me in the right direction
John
Comments
Autocomplete fields have no
Autocomplete fields have no way of affecting other form elements, nor do other form elements have no way of reacting to autocomplete fields.
The only way to do this would be to add a custom js script yourself. If I were to do it, I would probably add an 'onBlur' listener to the autocomplete, and taking the entered value, doing a quick query to the db, and then dropping the returned value into the age field. But you will see a slight delay with this, it won't be instantaneous, as it requires another query to the server in the background that won't happen until after the autocomplete call.
Full-time freelancer, always looking for work.
jaypan.com (my portfolio)
Autocomplete have no
Jay,
Thanks very much for answering my question. I'll have a look at the onBlur or perhaps rewrite the form as a multipart.
Thanks again
John