Hello,

I am using Zen sub-theme. I created a content type via

Content Management->Content types->Add content type

and I added a textfield called "name". I am trying to make it do auto-completion.
I need to supply a long list of predefined values so that a user can select any of them or type their own.
The list of values is stored in a database table.

In the theme's template.php, I added the following:

function mytheme_node_form ($form) {

$form['field_name'][0]['value']['#autocomplete_path'] = 'name_autocomplete';

return (drupal_render($form));
}

I defined the path "name_autocomplete" within Drupal and have a PhP function that supplies a suggested list of names.
I did not write any javascript. The "name" textfield with auto-completion is working except one thing.

I hope the auto-completion field works the same way as Drupal's "Tags" taxonomy. You type a phrase, drupal suggests a few, you select one; you type a comma, and then another phrase. You select one from what drupal suggests, the selected new value will NOT replace the existing field value, but is added to the end of the existing field value with a comma between them.

I believe I need to alter Drupal's javascript code. How to do this? How to do it the "Drupal hook" way so that javascript is kept modular and clean?

Thanks so much for any input!!!

All the best.

---------------------

Updated: you dont need to do any javascript work. Simply do the trick on the database side.