1

I have created a contact form by using webform module, in that I have added one component as reset and the type is select options.

My requirement is when I choose this reset option from that dropdown and submitted the form, I want to reset my form. I have no idea how can I achieve this. I tried following but not worked, please help me regarding this.

function test_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'webform_client_form_111') {
    $form['submitted']['reset']['#option'] = 'test_reset';
  }
}
function test_reset(&$form, &$form_state){ 
  $form_state['rebuild'] = FALSE;
}
0

You can write a simple jQuery script for achieving this.

$('select').on('change', function() {     // you can refine this with your field id.
  if( this.value == 'reset' ) {           // Replace value for your 'reset' option.
    $('#yourid').find('form')[0].reset(); // Replace id here
  }
})
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.