var place_input_count=1; var add_place_input=function(){ var new_input=document.createElement("input"); new_input.setAttribute("id", "place_input"+place_input_count); new_input.setAttribute("type", "text"); new_input.setAttribute("size", "7"); new_input.onkeydown=function(){if (!this.already_added) add_place_input(); this.already_added=1;} $('places').appendChild(new_input); var autocomplete_choices=document.createElement("div"); autocomplete_choices.setAttribute("class", "autocomplete"); autocomplete_choices.setAttribute("id", "autocomplete_choices"+place_input_count); $('places').appendChild(autocomplete_choices); new Ajax.Autocompleter( "place_input"+place_input_count, "autocomplete_choices"+place_input_count, "_find-place/", { paramName: "q", /*minChars: 1, indicator: 'loading'*/ } ); place_input_count++; }