drupal 7

Ajax Autocomplete Textfield for Nodes

function module_name_form() {
  $form = array();
  $form['nid'] = array(
    '#title' => t('Nodes'),
    '#type' => 'textfield',
    '#autocomplete_path' => 'example/autocomplete',
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
  return $form;
function module_name_menu() {  
  $items['example/autocomplete'] = array(
    'page callback' => '_module_name_autocomplete',
    'access arguments' => array('access example autocomplete'),
    'type' => MENU_CALLBACK
  return $items;

The Examples modules

If you are new to developing for Drupal 7 or upgrading from another version, the examples modules is a GREAT module for examples on how to develop for Drupal using the API. It gives you the basic of a lot of the common things you do when developing. Some examples included are theming (hook_theme), running cron job (hook_cron), forms (hook_form, hook_element_info), menu, node and so much more!!