how i can get dropdown option keep selected after loading a page with function onchange? currently i can just load the page according to selected value from my dropdown. and after loading page it's selected with first value be default.
<select id="extDropDown">
<option>Select Extension</option>
<option value="*">All</option>
<option value="zip">ZIP</option>
<option value="rar">RAR</option>
<option value="php">PHP</option>
<option value="html">HTML</option>
<option value="htm">HTM</option>
<option value="jpg">JPG</option>
<option value="bmp">BMP</option>
<option value="txt">TEXT</option>
<option value="docs">DOCS</option>
<option value="xlsx">XLSX</option>
<option value="xls">XLS</option>
</select>
$( document ).ready(function() {
$( '#extDropDown' ).bind( 'change', function( e ){
document.location.href = "?dir=<?php echo $dir; ?>&action=loadfiles&ftype=" + $( this ).val();
});
});
Since you are using JQuery, you can do this
Update Fixed typo