Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:16:31+00:00 2026-06-09T09:16:31+00:00

I have two fields – end and start date(daterange) and I should pass them

  • 0

I have two fields – end and start date(daterange) and I should pass them into controller and reload this page.

Here is my code from view:

    <%= form_tag(:controller => "financial_reports", :action => 'index', :method => 'post') do%>//maybe this line should be edited
   <%= datepicker_input "report","start_date", :dateFormat => "dd/mm/yy" %>
  <%= datepicker_input "report", "end_date", :dateFormat => "dd/mm/yy"%>
  <%end%>

and generated HTML() :

  <form accept-charset="UTF-8" action="/financial_reports?method=post" method="post"...>
  <input id="report_start_date" name="report[start_date]" size="30" type="text" class="hasDatepicker"><script type="text/javascript">
<input id="report_end_date" name="report[end_date]" size="30" type="text" class="hasDatepicker"
    <input class="btn wide" id="btn-report" name="commit" type="submit" value="Run Report">
  </form>

Can I get datepicker value like this :

      $('#datepicker').datepicker({
    onSelect: function(dateText, inst) {
  $("input[name='report[start_date]']").val(dateText);
    }
});

and I need to pass them into controller and reload this page, because in this page controller.

HERE I NEED TO PASS JQUERY VALUE

    @financial_reports = current_user.financial_reports.where(:created_at => start_date.to_date..end_date.to_date)

or I should add another action or method ? What you can suggest ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:16:33+00:00Added an answer on June 9, 2026 at 9:16 am

    In my opinion, using AJAX and not reloading the page is a best bet here. You’re simply trying to update some data, and there’s no reason to perform a full page-refresh to do that. I’m not a RoR aficionado, but it would seem that we can send the data to the controller by doing ->

    $.ajax({ 
      type: 'POST', 
      url: 'path/to/controller', 
      data: {'start_date' : $("input[name='report[start_date]']").val(), 
            'end_date' : $("input[name='report[end_date]']").val() }, 
      success: function(data){
        //data is whatever you RETURN from your controller. 
        //an array, string, object...something 
      } 
    });`  
    

    In your RoR controller, you’ll get the params by doing…

    var the_start = params[:start_date],
        the_end = params[:end_date]
    

    Now you’ve got the data in your controller, you can apply the method to it. Then when you’re ready to send the data back, return, print, whatever you do to send data to the page.

    Also, RoR by default (when accessing a controller) expects to output a template to the view, since we just want to update data, you’ll need to stop that default action using something like ->

    render :layout => false
    

    I hope this was helpful. I’m really not a RoR expert, but this is the method I used in the few times I dabbled.

    Goodluck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have two fields start and end, both are dates, I want to write a
I have two fields like this Field1 : Field2 - I have them stored
I have a table name wishlist . In this I have two fields user_id
I have two fields, one with the purchase date and one with the lifespan
I have two fields in a form (ip:port) seperately. I want to add them
I have two fields in sql date1 varchar(4) and date2 varchar(4) . The date
In my C# program (at this point) I have two fields in my form.
I have two fields on the form ( forgotpassword form ) username and email
I have two fields in separate linked tables with the same data, but different
I have two fields on my web page ie: BookAuthor and BookDescription.On submit,the page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.