Solved

How to append the selected date to a hidden input using jquery ui datepicker?

Posted on 2014-10-22
4
499 Views
Last Modified: 2014-10-23
Experts,

When using the jquery ui datepicker, I'd like to append the date the user selects to a hidden input field so that I can pass the value upon form submission.  Any assistance you could provide would be much appreciated.

Here's my fiddle which shows my current working code:

http://jsfiddle.net/bdbarrera/tf1vrf0v/

Just not sure how to modify the javascript to grab the date once it is selected?

Cheers!
0
Comment
Question by:evibesmusic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 35

Assisted Solution

by:Robert Schutt
Robert Schutt earned 300 total points
ID: 40398790
use onSelect to add a callback function:
            //CREATE CALENDAR OBJECT
            $("#calendar").datepicker({autoSize:true, onSelect:function(selectedDate, objDatePicker){
                $('#stoppage_date').val($('#stoppage_date').val() + ',' + selectedDate);
            }});

Open in new window

updated fiddle: http://jsfiddle.net/robert_schutt/tf1vrf0v/6/
(note that I used a TEMP visible input to more easily check that it works)
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 200 total points
ID: 40399133
also hide your calendar container with CSS else we need to click twice on the button the first time :
http://jsfiddle.net/tf1vrf0v/7/
0
 
LVL 11

Expert Comment

by:Murfur
ID: 40399146
Daft question for you: why have a hidden field and not just capture the date selected from the date field on form submission?
0
 

Author Closing Comment

by:evibesmusic
ID: 40399646
@All:

Thank you very much for the assistance. Much appreciated.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question