This code works but for some reason if you use it in php, it will reload and take you to the top of the page when you make a selection, and I can't use that because is for a long form, and the part where I'm using this is kind of at the bottom, so it would be annoying to the user to have the page reload and take you to the top of the page everytime you make a selection, idk if maybe I could fix this but I have no idea
<!DOCTYPE HTML>
<html>
<head>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$("#checkAll").on("change", function() {
$(':checkbox').not(this).prop('checked', this.checked);
});
window.onload = function () {
var cookies = document.cookie,
sidx = !!cookies ? cookies.match(/myDDIdx=([0-9]+?);?/) : false;
if (!!sidx && sidx.length >= 2) {
document.getElementById("Selection").selectedIndex = sidx[1];
}
};
document.getElementById("Selection").onchange = function () {
document.cookie = 'myDDIdx=' + this.selectedIndex + '; path=/;';
window.location = this.options[[this.selectedIndex]].value;
};
</script>
<select id="Selection" class="sorter" style="float:right;margin-right:8px;">
<option value="">Sort by</option>
<option >Code</option>
<option value="?orderby=1">Title A-Z</option>
<option value="?orderby=2">Title Z-A</option>
<option value="?orderby=3">Brand</option>
<option value="?orderby=4">Lowest price</option>
<option value="?orderby=5">Highest price</option>
<option value="?orderby=6">Lowest Quantity</option>
<option value="?orderby=7">Highest Quantity</option>
</select>