remote_function :with parameters from other form fields

I'm building a form where I have a set of radio buttons. When any of
these are selected I make an AJAX call that needs some values from
other fields in the form, but I'm having problems getting those values
and maybe someone can help.

I have the following code which is essentially repeated for each of
the radio buttons:

<%= radio_button_tag(:recurrence_period,
CalendarRepeatingEvent::RECURRENCE_PERIOD_MONTHLY_BY_DATE,
@recurrence_period ==
CalendarRepeatingEvent::RECURRENCE_PERIOD_MONTHLY_BY_DATE, {:onchange
=> remote_function(:with => "'recurrence_period='+this.value
+'&recurrence_frequency=#{@recurrence_frequency}&occurrence_number=#{@occurrence_number}'", :url
=> {:action => 'select_recurrence_period' })}) %>
<label for="recurrence_period">Monthly</label>

Note that the 2 values I'm trying to pass back are where I have
@recurrence_frequency and @occurrence_number... these are just
placeholders because they're really instance variables passed when the
form is initially setup and I just wanted to see if something got
passed back.

elsewhere in the form are the elements (id='frequency' and id='count')
I want to pull values from and pass back... here's that code:

Every:
Frequency:
<span id='frequency'>
<%= text_field_tag(:recurrence_frequency, @recurrence_frequency, :size
=> 2) %>
</span>
<br/>
<br/>
How many times?
<span id='count'>
<%= text_field_tag(:occurrence_number, @occurrence_number, :size => 4)
%>
</span>

(I hope this code is easy to read as sposted)

I tried using the Prototype utility method $F to pull the values (e.g.
$F('frequency')), but either that doesnt work or I'm doing it wrong.

Anybody familiar with this kind of problem?

I'd suggest wrapping everything in a larger container, and then use
the handy observe_form helper.

<div id="schedule">
... radio buttons...
... frequency ...
...occurence...
</div>
<%= observe_form 'schedule', :url=>your_target_path %>

This approach will serialize the input elements of 'schedule' (the
container) any time any one of them changes. You don't need to add
all that messy js script to your checkboxes -- the helper renders one
observer that handles it for you.

Thanks, Andy!

I changed the form before I got your answer, but observer_form looks
good... thx for the tip.