title: jQuery, text match defaults select
body: <p>Using: Rails and jQuery</p>
  
  <p>I have a form with a Url textbox input in which a user can put a url such as:</p>
  
  <p><a href="http://www.webshop.com/article/123" rel="nofollow">http://www.webshop.com/article/123</a></p>
  
  <p>url is an attribute of @product.</p>
  
  <p>In the same form I also have a dropdown populated with stores (Store.all). The store has an attribute store.short_url that could be "www.webshop.com". </p>
  
  <p>I want to use jQuery so that when a user types in <a href="http://www.webshop.com/article/123" rel="nofollow">http://www.webshop.com/article/123</a> in the url-textbox I want to compare that with the Store objects and see if that store is in the database which short_url matches the domain name and if so, default that Store in the dropdown.</p>
  
  <p>The string matching should not be a problem but how do I handle this in jQuery?</p>
  
  <ol>
  <li>Fill out the url field</li>
  <li>When text field is out of focus do:</li>
  <li>Find Store with matching url</li>
  <li>Set that store as default</li>
  </ol>
  
  <p>Any help would be much appreciated!</p>