X-Git-Url: http://git.datanom.net/qtadmin.git/blobdiff_plain/67d5e2dd3c347e7dccf4429fa204e9b9d76b2aed..7d080341a23c30924f88d847dc24e4b55f198ae5:/js/forms.js diff --git a/js/forms.js b/js/forms.js index d4ad9c9..1460abd 100644 --- a/js/forms.js +++ b/js/forms.js @@ -1,13 +1,39 @@ /* vim: set ts=4 tw=4 sw=4 noet: */ function updateRowsPerPage() { + var pos; + var url; + var base; + var href; + var rowsPerPage = document.getElementById("rows"); var link = document.getElementsByTagName('a'); + var found = false; for (var i = 0; i < link.length; i++) { - var url = link[i].href; - var pos = url.search('rowsperpage'); + url = link[i].href; + pos = url.search('rowsperpage'); if (pos >= 0) { - var base = url.slice(0, pos); - alert('base: ' + base); + found = true; + base = url.slice(0, pos); + href = base + 'rowsperpage=' + rowsPerPage.value; + link[i].href = href; } } + if (found == false) { + pos = location.href.search('rowsperpage'); + if (pos >= 0) { + base = location.href.slice(0, pos); + } else { + base = location.href; + } + if (location.href.charAt(location.href.length) == '?') { + href = base + 'rowsperpage=' + rowsPerPage.value; + } else { + href = base + '?rowsperpage=' + rowsPerPage.value; + } + } else { + pos = location.href.search('rowsperpage'); + base = location.href.slice(0, pos); + href = base + 'rowsperpage=' + rowsPerPage.value; + } + location.href = href; }