Last updated October 26, 2010. Created by kenorb on June 22, 2009.
Edited by gapa, LeeHunter, JohnNoc. Log in to edit this page.

Ajax Trigger module allows you to do specified actions on the server on JavaScript events on specified fields.

Example #1 - Calculating price in real-time using hook_ajax_trigger

1. Active Javascript Events for specified Field on Field Settings Page (admin/content/node-type/party/fields/field_name)
2. Example code:

* Implementation of hook_ajax_trigger().
function foo_ajax_trigger($form, $field, $op) {
$form_id = $form['form_id'];
  if (
$form_id == 'my_form_name') {
// Load required values from form
$price = (int)$form['field_foo'][0]['value'];
$div = 'Calculated price: &pound;'.number_format($price,2);
$code = '
      if ($("#price").size() == 1) {
      } else {
        $("#edit-submit").before(\'<br><div id="price">'
. $div . '</div>\');

Looking for support? Visit the forums, or join #drupal-support in IRC.


Hey, can you tell me where to save this Code! in a new Module? HELP PLEASE

You need to add this code as a hook implementation in your module. The 'foo' in the function name refers to your module name.

NVL Sateesh
Drupal Geek at New Target, Inc.

How would the jquery code look in this example?

Joel Box - Mondial-IT

where i will have to put this code..& how it will be bind with cck-field..can you tell me step by step process

hi do you think I can use this on the uc auction module so that I can have live auctions?
if yes please tell me where i can put the code