Can I use ajax to target multiple form elements from one input? I'm trying to use ajax to update two different parts of a drupal form from just one form input blur.

I have the standard ajax stuff on my input:

$my_form['my_input']['#ajax'] = array(
  'callback' =&gt; 'my_callback',
  'wrapper' =&gt; 'my_target_div',
  'event' =&gt; 'blur',
);


This is working well, swapping out my div when the input is updated ... however I also want to update another form input elsewhere in the form with different code as a result of the blur on my original input.

Is this possible, any ideas?

Edit: For clarity, here's my real world example:


Content type 'movie'
Added field 'primary_title'
When 'primary_title' is updated my ajax callback checks for similar strings and returns html.
The html from the callback is inserted into an empty div.

That part is working great!


I'm trying to also modify the standard node 'title' input, giving it the value of 'primary_title' after I have done some regex to tidy up the string (removing "The" or "A" from the start etc) The result will be two title fields, one with the complete title 'primary_title' and one trimmed 'title' that will be useful for sorting and displaying records.
It appears that you can target different parts of a form using ajax commands, however you must choose to return only one of either:


HTML or
A renderable array or
An array of AJAX commands


In the situation I originally wrote about, I was trying to return both an array of AJAX commands and a renderable array, which doesn't seem possible.

Code in the examples module demonstrates targeting different parts of a form using an array of AJAX commands:

function ajax_example_advanced_commands_html_callback($form, $form_state) {
  $text = $form_state['values']['html_command_example'];

  $commands = array();
  $commands[] = ajax_command_html('#html_div', $text);
  $commands[] = ajax_command_replace("#html_status", "&lt;div id='html_status'&gt;Updated html_command_example with text=$text;  " . date('r') . "&lt;/div&gt;");
  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


In this code sample, #html_div is getting $text, and separately #html_status is getting "Updated html_command_example with text=$text;  " . date('r') . ""

Two different locations on a form with two different pieces of information from the one ajax callback!

Looking again at what I was working on, I realized that I didn't need to return the node title field at all. It will only be a utility field, used for sorting data in lists.

I have hidden the field on the node form and it is populated the second time my form is built when my original ajax callback is triggered.