views:

24

answers:

1

I tried modifying the Jquery ui datepicker, but it didnt work in Ie7 and chrome.

but since im not a javascript expert I need to find a premade solution, something that makes certain days links.

Thank you

+1  A: 

I'm not sure what you're exactly trying to do, but you can capture the date selection in the jQuery UI datepicker by wiring up the onSelect event handler:

$("#myDate").datepicker({
     onSelect: function(date, inst) {
                  //do something here with the selected date
               },
     //...
})

The date parameter passed in is the text of the date, and the inst parameter is the instance of the datepicker. Depending on how you want to link to pages based on date, you could take the date text that's passed in to the onSelect handler and navigate to that page accordingly.

If you have more info on how you want to link, please add it and I'll respond.

Thanks. Hope this helps.

David Hoerster
You can also implement the beforeShowDay event handler, which is called for each date in the datepicker before it's displayed. You can set whether the date is selectable and also set the appropriate CSS class(es) for that date.
David Hoerster
Yes I want certain days to be underlined and linked accordingly. Right now I have json fed in with the link. So how do I use beforeShowDay?
Adam
ok so for instance why can I not set the color for my beforeShowDay class? I set an "aLink" class and can change font-size but not color.
Adam
Here's a quick demo I put together on jsFiddle. It shows using the beforeShowDay event handler to disable weekends and also set tooltips for each day.http://jsfiddle.net/yc7sp/
David Hoerster
I also updated it to assign a class to weekdays to make the font size larger than weekend days. This illustrates how to set a class in beforeShowDay also.
David Hoerster
thanks. I notice that the actual days arent given, but the number of the day of the week. Can I choose a specific date to change style or will I have to calculate that the 14th of july is a certain day of the week?
Adam
I updated the sample (http://jsfiddle.net/yc7sp/4/). I use date.getDate() to return the number of the date (14 for the 14th, for example) and use date.getDay() to get the day of the week. So you don't need to know that the 14th is a Wednesday. You can use a combination of date functions.Check out this reference on the JavaScript Date object: http://www.w3schools.com/jsref/jsref_obj_date.aspHope this helps!!
David Hoerster
thanks this is perfect.
Adam
How would I incorporate an array to that if statement. Im trying to use .inArray but with no luck in trying to add styles to different specific days.
Adam
this is getting very complicated.This is what I had before: http://pastebin.com/PNZ3xNjtthe reason im not using it is that it doesnt work in ie
Adam
ok i've been working on my own version by building a multidimensional array. but although the beforeShowDay can receive smaller variables, the building of the array takes too long before beforeShowDay executes. Is there any way around that?
Adam