Kornkrit Leelhaphunt
Kornkrit Leelhaphunt

Reputation: 168

How to refresh dropdown when user back and previous button

When select data in dropdown list and click submit or save (Redirect to another page)

Then click back or previous every browser like IE , Chrome , Firefox , Data in dropdown list have remember the latest information did you select ....

The question is how to clear or reset that .

Upvotes: 1

Views: 3500

Answers (1)

Kornkrit Leelhaphunt
Kornkrit Leelhaphunt

Reputation: 168

Oops ... i found answer in this link http://www.jquerybyexample.net/2012/03/how-to-reset-dropdown-using-jquery.html

Below code will find the first item in the list and make it selected. 1

$('#DropDownList1').find('option:first').attr('selected', 'selected');

Below code will find the item with value o and selects it. If the first item in your dropdown list starts with -1, then use -1 as argument. 1

$('#DropDownList1').val(0);

Below jQuery code will set the very first item of the list as selected. 1

$('#DropDownList1 option:eq(0)').attr('selected','selected');

Below jQuery code will set selectedindex of dropdown list to 0, which is the first item of the dropdown list. 1

$('#DropDownList1').get(0).selectedIndex = 0;

If you know any other way to reset the dropdown then please let us know. We will add your code in this list and also give credit you for the same.

Upvotes: 1

Related Questions