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 8650471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:49:51+00:00 2026-06-12T13:49:51+00:00

At the top of a page I have a javascript datepicker. The selected date

  • 0

At the top of a page I have a javascript datepicker. The selected date is stored in the variable newDate

Lower I have a form in rails like so:

<%= form_for(@checkin) do |f| %>
  ...
<% end %>

I want the date selected above to get passed as a parameter upon form submission. I want to do something like this:

<%= f.hidden_field :checkedin_at, :value => newDate %>

But I’m pretty sure I can’t mix client-side and server-side code like this. Is there another way to pull this off?

  • 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-12T13:49:52+00:00Added an answer on June 12, 2026 at 1:49 pm

    You can create a hidden field like you did, and from javascript you can set the value of that hidden field to the actual value.

    Erb part:

    <%= f.hidden_field :checkedin_at, :value => '', :id => 'date' %>
    

    Javascript part:

    document.getElementById('date').setAttribute('value', newDate);
    

    You can do javascript set part when you got the new date value or on submit it’s your decision.

    Modifying

    If you want to modify an already saved checkedin_at variable later, then you need to read it before. So you may need to set the actual value in Erb from the model, and read with:

    newDate = document.getElementById('date').getAttribute('value');
    

    Sidenote

    It’s a good idea to do it in an unobtrusive way with javascript. To Be prepared for browsers without javascript support on people with disabilities who cannot use normal browsers.

    So a simple HTML solution is a nice to have with visible date field with parsable (not a timestamp) date field.

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

Sidebar

Related Questions

So I have a page like this you look at. On top I have
At the top of my page I have a div that spans the page,
So on my page I have a menu that is fixed to the top
Hi I'm looking to have an alert banner at the top of page be
I have a page with 5 buttons on top. I want the area below
At the top of my page I want to have the title of the
I have one horizontally div on the top of my page with a height
I have a search at the top of the page in ajax and I
I have a page with elements, with relative position. style=position: relative; Some have top/left
I'm making a mobile web app. At the top of the page, I have

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.