views:

23

answers:

1

I have a link to a page on my site that has a data parameter in it. I want to use jQuery UI's Datepicker to set the parameter for the link. I've used Datapicker before, but only in forms. Is there a way to use it to set a URL parameter in the link? Thanks for reading.

+1  A: 

You could create a text input that the date picker works with, but make the text input hidden. Then, you can bind a change event to the text input that will grab the date entered via the date picker into your URL parameter.

kchau
@kchau: Thanks for your answer. I thought about doing that, but how exactly would I change the value of the URL parameter?
ben
So, I'm going to assume the URL in question will be the new URL the user will be directed to. So, if you're trying to add to the current URL the user is viewing, you can use window.location.href to access the current page URL, and then use string concatenation to append your new date parameter. If it's a URL in some anchor tag, you can just use jQuery to change the href attribute of that anchor and append the new date parameter.
kchau