title: Auto populate a text field based on another text field
body: <p>I am trying to auto-populate a text field based on the value of another input field. Currently trying to do this using observe_field helper like this:</p>
  
  <pre><code>&lt;%= observe_field(
          :account_name, 
          :function =&gt; "alert('Name changed!')",
          :on =&gt; 'keyup'
      ) %&gt;
  
  &lt;% form_for(@account, :html =&gt; { :id =&gt; 'theform' }) do |f| %&gt;
      &lt;label for="accountname"&gt; Account name &lt;/label&gt;
      &lt;%= form.text_field :name, :tabindex =&gt; '1' %&gt;
      &lt;label for="subdomain"&gt; Subdomain &lt;/label&gt;
      &lt;%= form.text_field :subdomain, :tabindex =&gt; '2' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>When the user enters text in the account_name text_field, I want to copy that convert into a subdomain (downcase and join by '-') and populate to subdomain text_field.</p>
  
  <p>But, in the process getting this error:</p>
  
  <pre><code>element is null
     var method = element.tagName.toLowerCase();   protot...9227640 (line 3588)
  </code></pre>
  
  <p>Where exactly am I going wrong here? Or is there a better way to do this?</p>