troubleshooting Question

Problem with datepicker and ajax post

Avatar of tjyoung
tjyoung asked on
JavaScriptAJAXjQuery
8 Comments2 Solutions462 ViewsLast Modified:
Hi,
I hobbled together some code with a datepicker that highlights dates from my DB and when you click on a date, it sends a post. It all works fine. The event dates are mm/dd/YY format but when they are added to my url for the post they look like:
contest_pause.php?contestdate=Thu%20Mar%2028%202013%2000:00:00%20GMT-0300%20(ADT)

Somewhere in my datepicker code it spells out the date instead of leaving it as is. Can you see how I can adjust the datepicker so it leaves the date as is? I've tried a hundred different ways and they fail.

var events = [ 
{ contestdate: new Date('03/26/2013') },{ contestdate: new Date('03/25/2013') },{ contestdate: new Date('03/31/2013') },{ contestdate: new Date('03/29/2013') },];



$( ".contestpicker" ).datepicker({ 
		autoSize: true,
		numberOfMonths: 1,
		minDate: 0,
		beforeShowDay: function(date) {
        var result = [true, '', null];
        var matching = $.grep(events, function(event) {
            return event.contestdate.valueOf() === date.valueOf();
        });
        
        if (matching.length) {
            result = [true, 'highlight', null];
        }
        return result;
    },
    onSelect: function(dateText) {
        var date,
            selectedDate = new Date(dateText),
            i = 0,
            event = null;
        
        
        while (i < events.length && !event) {
            date = events[i].contestdate;

            if (selectedDate.valueOf() === date.valueOf()) {
                event = events[i];
            }
            i++;
        }
        if (event) {
            $.post("assets/db/contest.php?contestdate=" + event.contestdate + "");
        }
    }
	});	
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros