1

I need to implement a dynamic yearly calendar, there will be a drop-down box which has up to 10 years from now, if a year was selected and the 'Set' button was pressed. A calendar for a whole year will be displayed in the JSP. Like this one:

enter image description here

This calendar will also be construct with check boxes, since I will use the Struts's html:multibox tag. Can someone give me an idea on how to do this in JS or jQuery?

Note: I am only allowed to use JSP, JS and jQuery. No AJAX or other stuff.

Carlo S
  • 63
  • 8

1 Answers1

0

If you want to handle everything in javascript (which I recommend), you can start by looking at these items:

  1. Capturing the selected year using .change() https://api.jquery.com/change/
  2. Get the list of days in each months Find all the days in a month with Date object?
  3. Create a dynamic tables to represent each months which contain checkboxes How do I create HTML table using jQuery dynamically?
  4. If you ever need to set the checkboxes' value from the server-side, just render them as hidden inputs or javascript variables values then use them to check/uncheck the checkboxes using jquery Setting "checked" for a checkbox with jQuery?

Since we are doing most of the things using javascript, avoid relying on struts taglibs (eg: html:multibox) because they are executed (rendered) before javascript.

Community
  • 1
  • 1
Yohanes Gultom
  • 3,782
  • 2
  • 25
  • 38