Fix for I want to attach the value of the url from the text field to the function that i am calling(sitestats_stats()). Is this possible

  1. function sitestats_getform(&$form_state) {
  2.   $form = array();
  3.   $form['url'] = array(
  4.     '#type' => 'textfield',
  5.     '#title' => t('URL'),
  6.     '#default_value' => 'http://',
  7.     '#size' => 20,
  8.     '#description' => t('URL for which the stats are checked'),
  9.     );  
  10.   $form['submit'] =array(
  11.     '#type' => 'submit',
  12.     '#value' => 'Go',
  13.     '#ahah' => array(
  14.       'event' => 'click',
  15.       'path' => 'sitestats/path',
  16.       'wrapper' => 'target_sitestats',
  17.       'method' => 'replace',
  18.       'effect' => 'slide',
  19.       )  
  20.     );  
  21.    $form['target'] = array(
  22.      '#type' => 'markup',
  23.      '#prefix' => '<div id="target_sitestats">',
  24.      '#value' => t(''),
  25.      '#suffix' => '</div>',
  26.      );  
  27.  
  28.   return $form;
  29. }
  30. function sitestats_stats(){
  31.   drupal_set_header('Content-Type: text/plain; charset: utf-8');
  32.   drupal_json(array('status' => TRUE, 'data' => 'Anything'));
  33. }
  34. function sitestats_menu(){
  35.  
  36.   $items['sitestats'] = array(
  37.       'title' => 'SiteStats',
  38.       'page callback' => 'sitestats_page',
  39.       'access arguments' => array('access sitestats'),
  40.       'type' => MENU_NORMAL_ITEM,
  41.       );
  42.   $items['sitestats/path'] = array(
  43.     'page callback' => 'sitestats_stats',
  44.     'type' => MENU_CALLBACK,
  45.     'access arguments' => array('access content'),
  46.     );
  47. return $items;
  48. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.