Auto complete form


#1

If I have table user (id, firstname, lastname, age, city)

And form: textboxes for firstname, lastname, age and select for city

Is it possible to auto complete form? Not only firstname or lastname,
but full form?
So if I enter lastname, and there is only one user with this name, so it
auto complete firstname, age and city.


#2

James B. wrote:

If I have table user (id, firstname, lastname, age, city)

And form: textboxes for firstname, lastname, age and select for city

Is it possible to auto complete form? Not only firstname or lastname,
but full form?
So if I enter lastname, and there is only one user with this name, so it
auto complete firstname, age and city.

Hello there,
Why don’t you try a form_observer to do the job?

Simple example:
(view)
<% form_for :foo, :id => “my_form” %>
<%= form.text_field :first_name%>
<%= form.text_field :last_name%>
<%= form.text_field :age%>
<% end %>
<%= observe_form :my_form, :frequency => 0.5, :url => {:action =>
search_result" } %>

(controller)
def search_result
@foo = User.find(:all, :conditions => [“first_name LIKE ?, last_name
LIKE ?”,params[:first_name], params[:last_name]])
render view again
end

I don’t now if what you want to do is a good idea, but… that is the
way I’ll do it (what does not mean that is the best way, I’m new in
Rails).

David S.