]> git.datanom.net - qtadmin.git/blobdiff - js/forms.js
First upload of wblist page
[qtadmin.git] / js / forms.js
index 0e411bb9213b603a2b1d1454585f55852f99f7c6..5d2bb3383b2fec50cab9ce6af4b828044afd33e9 100644 (file)
@@ -1,24 +1,43 @@
-/* vim: set ts=4 tw=4 sw=4 noet: */
+/* vim: set ts=4 tw=0 sw=4 noet: */
 
 function updateRowsPerPage() {
-    var rowsPerPage = document.getElementById("rows");
-    var found = false;
+    var pos;
+    var url;
+    var base;
+    var href;
     var link = document.getElementsByTagName('a');
+    var found = false;
+    var rowsPerPage = document.getElementById("rows");
+
+    if (rowsPerPage.value == '') {
+        rowsPerPage.value = '20';
+    }
     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) {
             found = true;
-            var base = url.slice(0, pos);
-            var href = base + 'rowsperpage=' + rowsPerPage.value;
+            base = url.slice(0, pos);
+            href = base + 'rowsperpage=' + rowsPerPage.value;
             link[i].href = href;
         }
     }
     if (found == false) {
-        /* current page has rows < current rows per page */
-        var href = location.href;
-        href = encodeURI('index.php?rowsperpage=' + rowsPerPage.value);
-        alert(href);
-        location.assign(href);
+        pos = location.href.search('rowsperpage');
+        if (pos >= 0) {
+            base = location.href.slice(0, pos);
+        } else {
+            base = location.href;
+        }
+        if (base.charAt(base.length - 1) == '?') {
+            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;
 }
This page took 0.146278 seconds and 5 git commands to generate.