Using Javascript in a rails form to modify DateTime fields
===

I have a form, and it has a date field on it. I would like to implement some javascript to do two things: provide a button to clear the date (set each select chooser to "") and another to configure the select choosers to correspond to a specific date.

What I have works, but it feels too heavy handed. Is there a better way? For example a way to re-render the form after adjusting values in the object being edited.

        <%= form_for @schedule do |f| %>
          <div class="field">
            <%= f.label :start %><br />
            <%= f.datetime_select :start, :include_blank => true  %> <%= submit_tag "Clear", :type => 'button', :id => 'clear_start' %> <%= submit_tag "Pull from Parent", :type => 'button', :id => 'parent_start' %>
          </div>
          <div class="actions" style="padding: 20px 0;">
            <%= f.submit %>
          </div>
        <% end %>
        
        <script type="text/javascript">
        	$(document).ready(function(){
        		$("#clear_start").click(function(){
        			$("#schedule_start_1i").val('');
        			$("#schedule_start_2i").val('');
        			$("#schedule_start_3i").val('');
        			$("#schedule_start_4i").val('');
        			$("#schedule_start_5i").val('');
        			return false;
        		});
        		$("#parent_start").click(function(){
        			$("#schedule_start_1i").val('<%= @parent.start.year %>');
        			$("#schedule_start_2i").val('<%= @parent.start.month %>');
        			$("#schedule_start_3i").val('<%= @parent.start.day %>');
        			$("#schedule_start_4i").val('<%= @parent.start.strftime("%H") %>');
        			$("#schedule_start_5i").val('<%= @parent.start.strftime("%M") %>');
        			return false;
        		});
        	});
        </script>
        