I would like to repopulate the select box on select change.
What i did so far (does not work):
$('select#mnt').change(function(){
var month = $(this).val();
var days = new Date(year, month, 0).getDate();
var toMonth = <?php echo $tomon; ?>;
var toDay = <?php echo $today; ?>;
var result='';
if (month!=toMonth) {
for(var i=1; i<=days;i++){
result += '<option>'+i+'</option>';
}
$('select#days').empty().html(result);
}
});
You don’t have the
yearvariable in that function. Do you create it elsewhere?Here’s a working example, with some changes: DEMO