Dear friends,

I have requirement were the textfield gets generated automatically using javascript, then how can i make it autocomplete. Traditional thing will not work as I am not generating textfield using form api.

Regards,
Niraj

Comments

nevets’s picture

Word of warning the textfield generate by javascript will not by default work with the forms API.

grobemo’s picture

nevets is right that Forms API isn't going to like your JS-generated form elements. For security, forms generally need to come from the server in order to be accepted. You may want to write a little module to send you the form that you want via AJAX/AHAH based on user input.

Once you inject the autocomplete-ready form into the DOM, you'll need to call Drupal.attachBehaviors() in order to activate the autocomplete.