php - Run JavaScript on form submit in Drupal 7 -
i have form few fields user should fill out. form have 2 hidden fields users current position (lat, long). have spent quite time trying find way fill these fields.
how want work this: when form submitted (jquery or onsubmit in form tag) javascript function asks device location should run. hidden fields filled result.
i have working code doing can't called drupal.
is there way run javascript function upon form submit in drupal or should find way it.
many thanks,
try add onclick
event submit button using #attributes.
$form['submit_button']['#attributes'] = array( 'onclick' => array("yourjscallback()"), );
or if have inside ['#attributes']
array, need add it.
$form['submit_button']['#attributes']['onclick'] = array("yourjscallback()");
Comments
Post a Comment