Show the value of a node-form field inside an AJAX field added via hook_form_alter() I have created a simple content type "reservation" with an integer field called "field_km" with a default value of 50.
On the node creation form, I want to have a markup field showing the value of the "field_km" field.
So, I have created a simple module with the following code:

/**
 * @file
 * Drupal Module : myresa
 * Adds custom code specific to this Drupal 7 site.
 */

function myresa_form_reservation_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form[‘box’] = array(
    ‘#type’ =&gt; ‘markup’,
    ‘#prefix’ =&gt; ‘’,
    ‘#suffix’ =&gt; ‘’,
    ‘#markup’ =&gt; ‘Price not computed',
  );

  $form[‘mybtn’] = array(
    ‘#type’ =&gt; ‘button’,
    ‘#id’ =&gt; ‘mybtn’,
    ‘#ajax’ =&gt; array(
      ‘callback’ =&gt; ‘myresa_callback’,
      ‘wrapper’ =&gt; ‘box’,
      ‘name’ =&gt; ‘mybtn1’,
    ),
    ‘#value’ =&gt; t(‘Compute the price’),
  );
}

function myresa_callback($form, $form_state) {
  $element = $form[‘box’] ;
  $element[‘#markup’] = «The price for » . $form_element[‘field_km’][‘#default_value’] . » km is 35 euros» ;
  return $element ;
}


The form shows the 'box' markup, the button, and when clicked the button activates the callback and shows the wanted text, but not the value of 'field_km'.
It is probably a simple syntax mistake, but it beats me.
function myresa_callback($form, $form_state) {
  $element = $form[‘box’] ;
  $element[‘#markup’] = «The price for » . $form_element


No wonder this doesn't work, where does $form_element come from? Also fields tend to be structured like $form[field name][$node-&gt;language][columname] (the latter being value in your case IMO)