title: Javascript not picking up attribute value
body: <p>Thanks to help here, I got a sample piece of code working When I tried to apply it to the real thing, something is not working quite.</p>
  
  <p>In my view (new.html.erb), I have the following:</p>
  
  <pre><code>&lt;%= f.hidden_field :addtl_attendee_payment, :value =&gt; Addtl_attendee_charge %&gt;
  </code></pre>
  
  <p>(Addtl_attendee_charge comes from a config file)</p>
  
  <p>and in my javascript file, I have the following:</p>
  
  <pre><code>function display_value() {
      var a = $("#addtl_attendee_payment");
      alert(a.val());
  }
  </code></pre>
  
  <p>and in another spot in my new.html.erb, I have the following:</p>
  
  <pre><code>&lt;script&gt;&lt;%= "display_value()" %&gt;&lt;/script&gt;
  </code></pre>
  
  <p>When I run this, I get "undefined" inside the alert box. If I look at the HTML (using firefly), here's what I get:</p>
  
  <pre><code>&lt;input id="payment_addtl_attendee_payment" type="hidden" value="500" name="payment[addtl_attendee_payment]"&gt;
  </code></pre>
  
  <p>Payment is the model name. This is the same type of code that worked for the test code. Any ideas?</p>
  
  <h1>Note:</h1>
  
  <p>Note again that the model name is Payment, and although I did not add payment to the attribute name, Rails added it automatically. I did try another variation on the javascript file:</p>
  
  <pre><code>function display_value() {
      var a = $("#payment_addtl_attendee_payment");
      alert(a.val());
  }
  </code></pre>
  
  <p>But that did not work either (getting the same message). I think that adding the payment_ is normal and is done by Rails (but I could be wrong, being a newbie)</p>