<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> $items["as/college/autocomplete"] = array(</div></div><div><div> 'title' => 'Autocomplete for agencies',</div></div><div><div> 'page callback' => 'college_autocomplete_callback',</div></div><div><div> 'page arguments' => array(3), // Note this is 3 based on the path ("my_special/path...") set above</div></div><div><div> 'access callback' =>TRUE,</div></div><div><div> 'access arguments' => array('access content'),</div></div><div><div> 'type' => MENU_CALLBACK,</div></div><div><div> );</div></div><div><div> return $items;</div></div><div><div>}</div></div><div><div><br></div></div><div><div>function college_autocomplete_form_alter(&$form, $form_state, $form_id) {</div></div><div><div> if($form_id == "webform_client_form_108" ){</div></div><div>// A better way to consolidate these fields into one... array?</div><div><div> $form['submitted']['college_1']['college_choice_1']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_2']['college_choice_2']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_3']['college_choice_3']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_4']['college_choice_4']['#autocomplete_path'] = "as/college/autocomplete"; </div></div><div><div> $form['submitted']['college_5']['college_choice_5']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_6']['college_choice_6']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_7']['college_choice_7']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> $form['submitted']['college_8']['college_choice_8']['#autocomplete_path'] = "as/college/autocomplete";</div></div><div><div> } </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> $matches = array();</div></div><div>// wrap my query with anything more for security?</div><div><div> $result = db_query_range("SELECT name FROM {term_data} WHERE LOWER(name) LIKE LOWER('%%%s%%')", $string, 0, 5);</div></div><div><div> while ($row=db_fetch_object($result)) {</div></div><div><div> $matches[$row->name] = check_plain($row->name);</div></div><div><div> }</div></div><div><div> print drupal_json($matches);</div></div><div><div> 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">--- </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"> <a href="http://Quevin.com">Quevin.com</a></font><br><font face="Courier New" size="3" class="f1"> <a href="http://twitter.com/Quevin">twitter.com/Quevin</a></font><br><font face="Courier New" size="3" class="f1"> <a href="http://linkedin.com/in/quevin">linkedin.com/in/quevin</a></font></div></body></html>