Replace whitspaces with dashes, make all lowercase
<p>I'm trying to combine some code and it's going badly wrong (because I'm rubbish at Javascript). This is my original code:</p>

<pre><code>function onSubmit(){
    document.forms["login"]["redirect_to"].value = document.forms["login"]["log"].value;
}   
</code></pre>

<p>I want to strip out the whitespaces and replace with dashes and make everything lowercase, this was my attempt:</p>

<pre><code>function onSubmit(){
    var str = document.forms["login"]["log"].value;
    str.replace(/\s+/g, '-').toLowerCase();
    document.forms["login"]["redirect_to"].value = str;
}
</code></pre>

<p>Where am I going wrong?</p>
