<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Do you see much wrong with this autocomplete module code (form_alter on Webform fields)? It works fine, but I think it can be cleaned up:<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>function college_autocomplete_menu() {</div></div><div><div>&nbsp;&nbsp;$items["as/college/autocomplete"] = array(</div></div><div><div>&nbsp;&nbsp; &nbsp;'title' =&gt; 'Autocomplete for agencies',</div></div><div><div>&nbsp;&nbsp; &nbsp;'page callback' =&gt; 'college_autocomplete_callback',</div></div><div><div>&nbsp;&nbsp; &nbsp;'page arguments' =&gt; array(3), // Note this is 3 based on the path ("my_special/path...") set above</div></div><div><div>&nbsp;&nbsp; &nbsp;'access callback' =&gt;TRUE,</div></div><div><div>&nbsp;&nbsp; &nbsp;'access arguments' =&gt; array('access content'),</div></div><div><div>&nbsp;&nbsp; &nbsp;'type' =&gt; MENU_CALLBACK,</div></div><div><div>&nbsp;&nbsp; );</div></div><div><div>&nbsp;&nbsp;return $items;</div></div><div><div>}</div></div><div><div><br></div></div><div><div>function college_autocomplete_form_alter(&amp;$form, $form_state, $form_id) {</div></div><div><div>&nbsp;&nbsp;if($form_id == "webform_client_form_108" ){</div></div><div>// A better way to consolidate these fields into one... array?</div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_1']['college_choice_1']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_2']['college_choice_2']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_3']['college_choice_3']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_4']['college_choice_4']['#autocomplete_path'] = "as/college/autocomplete"; &nbsp; &nbsp;</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_5']['college_choice_5']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_6']['college_choice_6']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_7']['college_choice_7']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp; &nbsp;$form['submitted']['college_8']['college_choice_8']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div>&nbsp;&nbsp;}&nbsp;</div></div><div><div>}</div></div><div><div><br></div></div><div><div>// A callback funtion to send back suggestion based on the bit of a string it receives.</div></div><div><div>function college_autocomplete_callback($string = '') {</div></div><div><div>&nbsp;&nbsp;$matches = array();</div></div><div>// wrap my query with anything more for security?</div><div><div>&nbsp;&nbsp;$result = db_query_range("SELECT name FROM {term_data} WHERE LOWER(name) LIKE LOWER('%%%s%%')", $string, 0, 5);</div></div><div><div>&nbsp;&nbsp;while ($row=db_fetch_object($result)) {</div></div><div><div>&nbsp;&nbsp; &nbsp;$matches[$row-&gt;name] = check_plain($row-&gt;name);</div></div><div><div>&nbsp;&nbsp;}</div></div><div><div>&nbsp;&nbsp;print drupal_json($matches);</div></div><div><div>&nbsp;&nbsp;exit;</div></div><div><div>}</div></div></blockquote><div><br></div><div>Thanks!</div><div><br></div><div>Kevin</div><div><br></div><div><font face="Courier New" size="3" class="f1">---&nbsp;</font><br><font face="Courier New" size="3" class="f1"></font><br><font face="Courier New" size="3" class="f1">Quevin, LLC</font><br><font face="Courier New" size="3" class="f1">&nbsp;<a href="http://Quevin.com">Quevin.com</a></font><br><font face="Courier New" size="3" class="f1">&nbsp;<a href="http://twitter.com/Quevin">twitter.com/Quevin</a></font><br><font face="Courier New" size="3" class="f1">&nbsp;<a href="http://linkedin.com/in/quevin">linkedin.com/in/quevin</a></font></div></body></html>