1

I have the following script with a UI Datepicker, but I need the date as a param in my URL.. I just can't seem to get the date formatted correctly in the URL.. The input box with the date are just fine but the date don't show up in my URL string..

I need the dateText variable to be formatted as "yyyy-mm-dd"

<script type="text/javascript">
    jQuery(function() {
    jQuery('#datepick').datepicker({ dateFormat: "yy-mm-dd" })({
        onSelect: function (dateText, inst) {
        window.location.href="reports?date=" + dateText;
    }
    })
});
</script>

Thank you..

2
  • What are you currently seeing? The date is not populated or the date is in the wrong format? Commented Oct 6, 2011 at 10:19
  • What error are you getting? The JavaScript you provided is incorrect. Commented Oct 6, 2011 at 10:43

1 Answer 1

3

Try this within your onSelect:

window.location.href="reports?date=" + $.datepicker.formatDate("yy-mm-dd", $(this).datepicker("getDate"));
Sign up to request clarification or add additional context in comments.

4 Comments

No problem. Please click on the tick icon to mark this as answered if it solved the issue, it makes us stack overflow people happy :)
What difference does this make, as opposed to the question?
@WilliamNiu not sure what you mean...?
I believe $.datepicker.formatDate("yy-mm-dd", $(this).datepicker("getDate")) == dateText.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.