title: replace multiple occurences in a string with javascript
body: <p>I have a selectbox with parameters as the value in the option, set like this:</p>
  
  <pre><code>&lt;option value="{$i.tileid}androoftiletypeeq{$i.model}andproducenteq{$i.producent}"&gt;{$i.name} {$i.$title}&lt;/option&gt;
  </code></pre>
  
  <p>I am trying to replace all "and" and "eq" to "&amp;" and "=", but I can only get my javascript to replace the first occurrence. The form is named / ID'ed "rooftile_select</p>
  
  <pre><code>$("#rooftile_select").change(function(event) {
  
    event.preventDefault(); 
  
    var data = $("#rooftile_select").serialize();                
    var pathname = window.location;
    var finalurl = pathname+'&amp;'+data;
  
    var replaced = finalurl.replace("and", "&amp;").replace("eq", "=");
  });
  </code></pre>
  
  <p>The last parameters in finalurl then looks like this:</p>
  
  <pre><code>&amp;rid=56&amp;rooftiletype=9andproducenteqs
  </code></pre>
  
  <p>Am I missing something?</p>