so i have this code that checks for dates and updates lists accordingly, now what i am trying to achieve is that when the for both the month and the year are set to null "mm" "yyyy" is set the day select list with one element "dd" with a value of null. but i have been having an error cannot set property 'value' of undefined. The first element in both the year and month s is set to a value of null.
this is the javascript function a guy here helped me come up with:
function monthDays (type) {
if(document.getElementById('monthof' + type).value == null || document.getElementById('yearof' + type).value == null)
{
var mod = document.getElementById('dayof' + type);
mod.length = 1;
mod[0].value = null;
mod[0].text = "DD";
}
else{
var month = parseInt(document.getElementById('monthof' + type).value, 10),
days = new Date(document.getElementById('yearof' + type).value, month + 1, 0).getDate(),
i;
var mod = document.getElementById('dayof' + type);
mod.length = days + 1;
mod[0].value = null;//this is where i am getting the error
mod[0].text = "DD";
for(i = 1; i < days+1; i++) {
mod[i].value = i;
mod[i].text = i;
}
}
}
html Birth: MM
<select id="dayofbirth" class="date" name="dayhofbirth">
<option value=null>DD</option>
</select>
<select id="monthofbirth" class="year" name="monthofbirth" onchange="monthDays('birth')">
<option value=null>MM</option>
</select>
<select id="yearofbirth" class="year" name="monthofbirth" onchange="monthDays('birth')">
<option value=null>YYYY</option>
</select>
</div>
the type is there to tell the function which it should edit, since in my html I have 2 date of births.
monthofbirth