Swap Values via Model in an onChange Event Within submit_tag Helper?

I'm new to RoR and (and programming) and am having trouble wrapping my head around how to get this working. What I'm trying to do is autofill a web form with values I select from a drop-down menu. I want to pull these values in from my Openers table.

My DB Model is called Openers and has the following fields:

id description subject body

My Controller is called bar_controller.rb and contains only 1 method which pulls all the records from Openers and orders them by description:

class BarController < ApplicationController

  def bar     @show_openers = Opener.find(:all, :order => "description")   end


I have 3 Views located user app/views/bar that make up a 2 column framed page. The first file is called index.html.erb and sets up the frames:

<frameset rows="10%, 90%"> <frame src="bar/bar" name="bar"> <frame src="bar/formtofill" name="formtofill"> </frameset>

The second file is called bar.html.erb and fills in the upper portion (top 10% of the page).

<%= javascript_include_tag :defaults %>

<% form_for :bar, :url => { :action => :bar } do |form| %>   <%= collection_select("openers", "opener_id", @show_openers, :id, :description ) %>   <%= submit_tag "insert opener",       :onClick => "parent.formtofill.document.form1.messagesubject.value='HERE_IS_SUBJECT', parent.formtofill.document.form1.messagebody.value='HERE_IS_BODY'" %> <% end %>

The last file is called formtofill.html.erb and fills in the bottom 90% of the page. It contains the form that I want to auto-populate with the values defined in bar.html.erb.

<form name="form1"> <div>   <p>Subject:</p>   <div>     <div>       <input type="text" style="width: 450px;" tabindex="1" id="messagesubject" name="messagesubject"/>     </div>   </div> </div>

<div>   <p>Body:</p>   <div>     <textarea style="width: 450px;" tabindex="2" id="messagebody" cols="20" rows="20" name="messagebody"/>     </textarea>   </div> </div> </form>

Right now I've got the descriptions populating the dropdown and the onClick will stuff the static HERE_IS_SUBJECT and HERE_IS_BODY into the correct form fields, but there are still a few things I'm having trouble with:

1) How do I access the subject and body info? 2) Once question 1 is solved, how do I update the HERE_IS_SUBJECT and HERE_IS_BODY values on an onChange event (within the submit_tag helper) with the matching Openers.subject and Openers.body values for the Openers.description selection?

Thanks in advance for any help!!!