0

how can i generate day based on selected.if user select month and year and click 'Generate' number of days display below and if select current month (July) and year(2014) only number current days will display.mean today is 8.thanks you

<select id="month" name="month" class="select">
 <option value="01">January</option>
 <option value="02">February</option> 
 <option value="03">March</option>
 <option value="04">April</option>
 <option value="05">May</option>
 <option value="06">Jun</option> 
 <option value="07">July</option>
 <option value="08">August</option>

<select id="year" name="year" class="select">
<option value="2011">2011</option>
<option value="2012">2012</option> 
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>
<button type="button" id="generate">Generate</button>
<div></div>
<table id="test" class="test">
<tr>
    <th>Day</th>
    <th>Value</th>
</tr>
<tbody>
    <td>1</td>
    <td><input type="text"/></td>
</tbody>

Code

GreenCat
  • 167
  • 1
  • 1
  • 15

1 Answers1

0

Something like this...

function daysInMonth(month, year){

   return new Date(year, month, 0).getDate();

}

From an answer here...

Community
  • 1
  • 1
shennan
  • 10,798
  • 5
  • 44
  • 79
  • no.. example if i select month (Jun), year(2014) and generate : result will appear number of days in row ,1/7/2014,2/7/2014/3/7/2014 until 8/7/2014 because current date now is 8/7/2014.previous date select will appear all.thanks you sir – GreenCat Jul 08 '14 at 01:13