Fix the JS but mentioned in the previous commit
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 01 Feb 2009 22:51:14 +0000
changeset 1167 346117bd30cf
parent 1166 558bd62ee9d4
child 1168 cb282e6baa1c
Fix the JS but mentioned in the previous commit Patch by: Sverre Rabbelier Reviewed by: Pawel Solyga
app/soc/views/helper/forms.py
--- a/app/soc/views/helper/forms.py	Sun Feb 01 22:48:48 2009 +0000
+++ b/app/soc/views/helper/forms.py	Sun Feb 01 22:51:14 2009 +0000
@@ -86,19 +86,22 @@
   """
 
   ONCHANGE_JAVASCRIPT_FMT = '''
-<script type="text/javascript"> 
-  function changeArg_%(arg_name)s(item) 
+<script type="text/javascript">
+  function changeArg_%(arg_name)s(item)
   {
     var idx=item.selectedIndex;
     item.selected=true;
-    var value=item.value 
-    var url = location.href 
-    var reg = /%(arg_name)s=\d+/ 
-    url = url.replace(reg, "%(arg_name)s="+value) 
-    if(url.match(reg))
-      document.location.href = url 
-   else
-      document.location.href = "%(page_path)s?%(arg_name)s="+value; 
+    var value=item.value;
+    var url = location.href;
+    var ourreg = /%(arg_name)s=\d+/;
+    var anyreg = /\w+=\d+/;
+    if(url.match(ourreg))
+      url = url.replace(ourreg, "%(arg_name)s="+value);
+    else if(url.match(anyreg))
+      url = url + "&%(arg_name)s=" + value;
+    else
+      url = "%(page_path)s?%(arg_name)s="+value;
+    document.location.href = url;
   }
 </script>
 '''