title: jQuery multiple character replace
body: <p>I have a very easy question. Unfortunately, I can't find the answer.</p>
  
  <p>I just made 2 simple input functions</p>
  
  <pre><code>Input 1:&lt;br /&gt;&lt;input type="text" id="i1" name="i1" /&gt;
  Input 2:&lt;br /&gt;
  &lt;input type="text" id="i2" name="i2" /&gt;
  </code></pre>
  
  <p>When changing input 1, I want to let appear the result in input 2. Also I want some characters being replaced and I want to make the characters lower case (in order to use it as an url).</p>
  
  <p>So I made the following jQuery code:</p>
  
  <pre><code>$("#i1").keyup(function() {
  var ptitle = $("#i1").val();
  $("#2").val(ptitle.replace(" ", "-").toLowerCase());
  });
  </code></pre>
  
  <p>This works good, except when I type a string that has multiple times the same character to replace. Then it only replaces the first time.</p>
  
  <p>For example: When I type in input 1: 'About this company' it will result in input 2: 'about-this company'. It should be: 'about-this-company'. Does anyone knows what is going wrong in my jQuery code?</p>