1

I have problem in shifting from one tab to another in HTML. I have two tabs, #tab1 and #tab2. I have one form in each of the tabs. when I enter details in #tab1, come to #tab2 and again go back to #tab1, the data I entered is not getting refreshed. The old values are retained back. I want a refreshed form.

I tried reloading the page itself by giving -

window.reload(true);

Whwn I did this, the page is displaying and disappearing within a fraction of second.

And also, tried refreshing the form alone by giving -

$('#formID').reset();

Then, the tab itself is not working. I am not getting any exceptions here. I am using jquery for shifting tabs.

Can any one please help me out in tracing out this problem?

Keerthi
  • 839
  • 1
  • 8
  • 14

2 Answers2

1

Consider this:

$("tabIdHere").click(function(){
  $('#formID')[0].reset();
});
qtgye
  • 3,580
  • 2
  • 15
  • 30
0

Try this one ..

$("tabIdHere").click(function() { $(this).closest('form').find("input[type=text], input[type=password],textarea").val(""); });

Clear form fields with jQuery check here too

Community
  • 1
  • 1
Udaya Sri
  • 2,372
  • 2
  • 25
  • 35