I want to use javascript within my php file.
The three drop down boxes involved are:

<select name="year" width="10">
<option value="<?php echo $curYear ?>"><?php echo $curYear ?></option>
<option value="<?php echo $curYear++ ?>"><?php echo $curYear++ ?></option>
<select name="month" width="10">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>                                        
<option value="04">04</option>                                       
<option value="05">05</option>                                                   <option value="06">06</option>
<option value="07">07</option>                                                <option value="08">08</option>
<option value="09">09</option>                                                <option value="10">10</option>                                               <option value="11">11</option>                                               <option value="12">12</option>

<select name="days" id="days" width="10">                                        


When the values in the month or year drop down boxes are selected or changed i want the days drop down box to be populated with the amount of days for that certain month and year.

I have looked at and tried many different code snippets but had no luck. I've never used JS so i'm not even sure where to put code exactly.

Any help would be appreciated.

6 Years
Discussion Span
Last Post by AleMonteiro

Here is a demo:


		function slcMes_change()
			document.getElementById("slcDia").options.length = 0;
			for(var i=0; i < 31; i++)
				document.getElementById("slcDia").options[i] = new Option(i+1, i+1);
		<select id="slcMes" size="1" onchange="slcMes_change()">
			<option value="0">Select</option>
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
			<option value="4">4</option>
		<select id="slcDia" size="1"></select>

You just have to do you logic.

Hope it helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.