Hello

In drupal 4.7, I installed a module called scriptaculous, then I can implement an autocomplete textfield in my module. E.g I can see a drop down list of users when use the code below


function user_autocomplete($string) {
  $matches = array();
  $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
  while ($user = db_fetch_object($result)) {
    $matches[$user->name] = check_plain($user->name);
  }
  print drupal_to_js($matches);
  exit();
}

However, when I update to Drupal 5.5, that function does not work any more and I cannot find out the module scriptaculous

Could you please help how to fix this problem

Regards
Many thanks

Comments

leotemp’s picture

Drupal uses JQuery not Scriptaculous as its JS framework so you will want to use JQuery instead unless you want to replace it with Scriptaculous all though i really prefer JQuery.

you can download the latest JQuery and get code samples here:
http://jquery.com

To force your theme to load your newly downloaded version of Jquery use something like this

	<?php
	$js = drupal_add_js('misc/jquery.js', 'core', 'header');
	$js = drupal_add_js(path_to_theme() . '/js/jquery.js', 'core', 'header'); //THIS IS WHERE YOU PUT THE NEW VERSION OF JQ//
	unset($js['core']['misc/jquery.js']);
	print drupal_get_js('header', $js);
	?>

Put the above snippet between the last CSS Style tag and your head tag so it is basically the last thing in your HEAD tag.

There is a ton of stuff out there for Jquery and there might even be an auto complete module already for Drupal, don't know.