Guest User

Untitled

a guest
Jun 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ****************************************************
  2. // Function to convert HTTP GET parameters to view parameters
  3. // This will validate the view cache
  4. // url - url of page to send view parameters to
  5. // id_array - list of HTTP GET id's
  6. // ****************************************************
  7.  
  8. function httpToViewParameters( url, id_array )
  9. {
  10.     url = url + '/';
  11.     if ( url === '//' ) url = '/';
  12.     for ( var id in id_array )
  13.     {
  14.         var element = document.getElementById( id_array[id] );
  15.         var val = '/' + ( element.value || '' ) + '/';
  16.         var name = '(' + element.name + ')';
  17.         if ( element.type == 'checkbox' && !element.checked )
  18.             val = '/0/';
  19.         if ( url.match( '/\(' + name + '\)\/(\w+)?\//' ) )
  20.             url = url.replace( name + '/' + RegExp.$1 + '/', ( val == '//' ? '' : name + val ) );
  21.         else if ( val !== '//' )
  22.             url = url + name + val;
  23.     }
  24.     window.location = url;
  25.     return false;
  26. }
Add Comment
Please, Sign In to add comment