0

ex I have 2 form input and 1 select form, when I select A 1 of the form hide and auto reset/clear.

basiclly i've done hide logic, but i can't reset it.

here's my code :

var employedTypeOption = $('#employedType-option');
employedTypeOption.on('change', function() {
  if (employedTypeOption.val() == 1) {
    $('#hourly-rate, #parttime-panel').show();
    $('#basic-salary').hide();
  } else if (employedTypeOption.val() == 0){
    $('#basic-salary').show();
    $('#hourly-rate, #parttime-panel').hide();
  }
});

any idea ?

Andrew Vanusi
  • 499
  • 4
  • 11
  • 27

1 Answers1

1

You can find all the text fields and textareas inside your form and reset their values. Like the following.

var employedTypeOption = $('#employedType-option');
employedTypeOption.on('change', function() {
  if (employedTypeOption.val() == 1) {
    $('#hourly-rate, #parttime-panel').show();
    $('#basic-salary').hide();

    $('#yourFormID').find('input[type="text"], textarea').val("");

  } else if (employedTypeOption.val() == 0){
    $('#basic-salary').show();
    $('#hourly-rate, #parttime-panel').hide();

    $('#yourFormID').find('input[type="text"], textarea').val("");

  }
});
Abdullah A Malik
  • 354
  • 2
  • 4
  • 12