// Update Form Data Dynamically

function daysInMonth(month, year)	 {
	 return 32 - new Date(year, month, 32).getDate();
 }
 
 function changeSelect (selectFieldID, monYearVal){
	var selectField = document.getElementById(selectFieldID);
	var splitVal = monYearVal.split('-');
	var mon = parseInt(splitVal[0]);
	var year = parseInt(splitVal[1]);
	
	//Wipe all options
	removeAllOptions(selectField);

	var now = new Date();

	if (mon == now.getMonth() + 1) {
		var start = now.getDate();
	}else{
		var start = 0;
	}
	
	for (var i = start; i < daysInMonth(mon-1, year); i++){
		var newOpt = new Option (i+1, i+1);
		selectField.options[i - start] = newOpt;
	} 
 }
 
 function removeAllOptions(field){			 	
	while (field.options.length){
		field.options[0] = null;
	}
 }