title: URL encoding with Javascript and then decoding with PHP
body: <p>I am wanting to url encode a string with Javascript, with the relevant part of the code being:</p>
  
  <pre><code>this.options[this.selectedIndex].value
  </code></pre>
  
  <p>or the full line:</p>
  
  <pre><code>&lt;select name="category" onChange="javascript:document.location.href='&lt;? echo '/' . $state . '/dir/'; ?&gt;' + this.options[this.selectedIndex].value;"&gt;
  </code></pre>
  
  <p>How can I url encode this with JS and then safely decode it with PHP using <code>urldecode</code>?</p>