Modifying a link with user input
<p>I'm working with a little chunk of code for a function, that I actually picked up in a different <a href="http://stackoverflow.com/a/7097818/1646851">question's answer</a>, which was a huge help. Though, trying to modify that snippet of script has been giving me some trouble: I'm trying to change this bit so that instead of changing displayed text with a link, it will modify the link with either static text (like "Click here") or a button element.  </p>

<pre><code>&lt;a id="reflectedlink" href="http://www.google.com/search"&gt;http://www.google.com/search&lt;/a&gt;
&lt;input id="searchterm"/&gt;
&lt;script type="text/javascript"&gt;
   var link= document.getElementById('reflectedlink');
   var input= document.getElementById('searchterm');
   input.onchange=input.onkeyup= function() 
      {
         link.search= '?q='+encodeURIComponent(input.value);
         link.firstChild.data= link.href;     
      }; 
&lt;/script&gt;
</code></pre>

<p>I would really like to have it a simple button that opens the modified link in a new window. I've tried looking for similar solutions and I'm sure I'm missing it just because I have no idea what I'm looking for. </p>
