Text field auto complete

I have a form with hierarchical text fields that could be improved if it
filled automatically the fields above the field in which information is
inserted and makes suggestions to the fields below. is it possible make
the text_field call a method when the user presses enter or selects an
option from the pull-down menu generated by the auto complete?

Thanks,
Ricardo