How to add button to webform to set value to a field Using Drupal 7 and Webform (both up to date), I'm looking for a way to add a button that when clicked, set the value of a field.

I can add a button using code like this:

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {

switch ($form_id) { 

case 'webform_client_form_ID':
  $form['alt_button'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; t('Alternative Action'),
);


I now need to figure how to perform the action of changing the value of one of the the webform field when this button is clicked...

Any help will be appreciate!
You will have to create a button in a

function hook_form_FORM_ID_alter(&amp;$form, &amp;$form_state, $form_id) {
    // Your code here.
}


and use the #ajax property of the button to update the field when the button is clicked.

The examples D7 module has some nice AJAX examples that will show you how the mechanism works.