Maybe do something simple like pass in a second parameter of the interval select id in the onClick event like:
<input type="checkbox" onclick="toggleAutoRefresh(this, 'interval');" id="reloadCB"> Auto Refresh
Then in the JS set a new variable with the interval selection and if the page reloads include the interval time after #autoreload and pass it between reloads in the anchor hash:
var reloading;
$(document).ready(function () {
$('#interval').change(function () {
if (document.getElementById("reloadCB").checked) {
var intervalSelection = $(this).find(":selected").val();
window.location.replace("#autoreload-" + intervalSelection);
reloading = setTimeout("window.location.reload();", intervalSelection);
} else {
window.location.replace("#");
clearTimeout(reloading);
}
});
});
function checkReloading() {
if (window.location.hash.substring(0, 11) == "#autoreload") {
var intervalSelection = window.location.hash.substring(12, window.location.hash.length);
reloading = setTimeout("window.location.reload();", intervalSelection);
document.getElementById("reloadCB").checked = true;
var intervalSelect = document.getElementById('interval');
var intervalOptions = intervalSelect.options.length;
for (var i = 0; i < intervalOptions; i++) {
if (intervalSelect.options[i].value == intervalSelection) {
intervalSelect.options[i].selected = true;
break;
}
}
}
}
function toggleAutoRefresh(cb, intervalID) {
var intervalSelection = $('#' + intervalID).find(":selected").val();
if (cb.checked) {
window.location.replace("#autoreload-" + intervalSelection);
reloading = setTimeout("window.location.reload();", intervalSelection);
} else {
window.location.replace("#");
clearTimeout(reloading);
}
}
window.onload = checkReloading;
Haven't tested any of this and probably not the most elegant solution but first thing that came to mind.
Edit: Added some code to set drop down to value passed through hash tag as well as some JQuery to detect change of value on drop down and set new interval time.