title: Change value of hidden_field_tag with JS (prototype & Rails 3)
body: <p>I'm riding Rails 3 and using Prototype. That said I'm only really asking a JS question.. </p>
  
  <p>I have a form, it's pretty simple. In the form I have a hidden field tag:</p>
  
  <pre><code>&lt;%= hidden_field_tag(:instructor_id, @instructor.id) %&gt;
  </code></pre>
  
  <p>That's all fine and well when I am submitting the form to one particular instructor.</p>
  
  <p>I have another page, however, which displays a lot of instructors. Rather than put the instructor id there myself, as in the code above, I'd like to change the value of the hidden field depending on which submit button is pressed.</p>
  
  <p>Ie, one form, several submit buttons. The form will submit and all being well the user will be able to go on and hit another submit button, sending their data through to another instructor. To achieve this I want to use javascript to alter the value of my hidden field on click. </p>
  
  <pre><code>    &lt;%form_for :call_back_request, :remote =&gt; true, :url =&gt; {:action =&gt; "call_back_request"} do |c| %&gt;
      &lt;%= hidden_field_tag(:instructor_id, @instructor.id) %&gt;
      &lt;%= hidden_field_tag(:pr_ok, true) %&gt;
      &lt;%= c.text_field :first_name, :class =&gt; "profilesmstext" %&gt;
      &lt;%= c.text_field :last_name, :class =&gt; "profilesmstext"%&gt;&lt;br /&gt;
      &lt;%= c.text_field :postcode, :class =&gt; "profilesmstexta"%&gt;
      &lt;%= c.text_field :telephone_number, :class =&gt; "profilesmstext" %&gt;
      &lt;%= c.submit, :value="Go!" %&gt;
  </code></pre>
  
  <p>That's the simple one instructor version of the form, essentially what I'm talking about doing is putting a loop of submit buttons and instructor ids in there.</p>
  
  <p>So I'll have a loop (pseudo code..)</p>
  
  <pre><code>    @instructors each do |i|
        &lt;%=c.submit, :value =&gt; "go!", :onclick =&gt; "javascript to change hidden field value"%&gt;
       &lt;script / js&gt;
       &lt;function doChicagoShuffleOnId etc &gt;
       &lt;/script&gt;
      &lt;%end%&gt;
  </code></pre>
  
  <p>So My question is - what is the js to change that hidden field tag?
  Additional question - This makes perfect sense to me, may be rubbish, if there is a more sensible solution please let me know!</p>
  
  <p>Thanks!</p>