Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-10-22
4
Medium Priority
?
572 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 1200 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 800 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

670 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