title: Click link and Insert text from hidden field into input field, more than 1 time and replace the text in the input field
body: <p>Click link and Insert text from hidden field into input field, more than 1 time and replace the text in the input field. </p>
  
  <p>Now my code only can insert text when the input field is empty, but I want it to replace the text if I click the "TestName" button</p>
  
  <p>Anyone can help me? It doesn't matter if its javascript/Jquery</p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;    
  &lt;script type="text/javascript"&gt;
  
  function SetSearch(val, search) {
   $('input[id ^="SearchForm"]').each(function (index) {
    var s = "SearchForm" + search;
    if ($(this).attr("id") == s) {
      $(this).attr("value", val);
      return false;
    }
  });
  }
  &lt;/script&gt;
  &lt;a href="javascript:SetSearch ( $('#Name').attr('value'), 'Name' );"&gt;
  TestName
  &lt;/a&gt;
  
  &lt;input id="Name" name="Name" type="hidden" value="TestName" /&gt;
  Name
  &lt;input name="Name" type="text" id="SearchFormName" value=""  /&gt;
  </code></pre>
  
  <p>My fiddle <a href="http://jsfiddle.net/fTpwF/2/" rel="nofollow">http://jsfiddle.net/fTpwF/2/</a></p>