Drupal Questions & Answers

Ask and answer Drupal related questions! No question too simple or complex!
1freethinker's picture
Asked by on Sat 24th Sep 2011
Trigger submit via onchange event of select box

I need to modify the code below so that the event is triggered from the select button directly ie I want to remove the submit button all together. (It is a select box to choose Currency and I have noticed it is normal on most websites simply to apply the change in currency as soon as it is selected in the select box.)

function commerce_multicurrency_selector_form($form, &$form_state) {
  $form['selected_currency'] = array(
    '#type' => 'select',
    '#options' => commerce_currency_code_options_list(),
    '#default_value' => commerce_multicurrency_get_user_currency_code(),
  );
  $form['save_selected_currency'] = array(
    '#value' => t('Save'),
    '#type' => 'submit',
  );
  return $form;
}

An example of the html/javascript I need.
<select onchange="document.getElementById("formId").submit()">

Thanks for your help,

Neil :)

Commenting on this Drupal Question is closed.