observe_field, how to use input to toggle checkbox?

This may seem like a bit of a silly question, but here's the reason:

I have an app where a large number of options may need to be selected.
Some are simply on/off with a checkbox but others have an additional
text input field associated with them. This is OK if users read the
instructions or they only select an on/off option, but sometimes for the
options with additional text they simply type into the input field and
neglect to tick the box as well. One way around this would be to
re-write the code to remove the requirement for checkboxes on
everything, but before doing that I would like to try using
observe_field to tick the box if they start typing text in the field. Is
that possible?

So far I have something like this:

<%= observe_field "text_input[#{parameter}]", :update =>
"check_box[#{parameter}]", :parameters => 1, :frequency => 0.5 -%>

This does not work. Is anyone able to suggest how this might be fixed?
Thanks.

You could use the JS onblur to enable the check box.
<%= text_field_tag "text","field" :onblur =>
'check_text_field_for_text(this)' %>
then use a js function to check the text box for text and set the
checkbox accordingly.

Chris Habgood wrote:

then use a js function to check the text box for text and set the
checkbox accordingly.

Thanks. So, I now have this:

<%= text_field_tag "text_value[#{var}]","", :onblur =>
"check_text_field_for_text(#{var})" -%>

...and:

<script type='text/javascript'>
function check_text_field_for_text(field)
{
  if (document.form_name.text_value[field].value == null)
  {
    document.form_name.tick_box[field].checked = true
  }
}
</script>

Still no luck, though. Presumably I am not referencing the name of the
checkbox correctly, but I am not sure of the nature of the error.

I have finally had some success, and it turns out that it was as simple
as this:

<%= observe_field("text_input_#{parameter}",:function =>
"check_box_#{parameter}.checked=true") -%>