<div style="margin-top: 7px;">
<?php if (is_array($priorities)): ?>
<?php foreach ($priorities as $k=>$priority): ?>
<div class="radio radio-<?php echo $priority['CLASS']; ?> radio-inline" onchange="autoInsertDate()">
<input type="radio" name="priority" id="radio<?php echo $priority['ID']; ?>" value="<?=$priority['ID']?>, <?=$priority['DAYS']?>" <?= isset($saved_priority) && $saved_priority==$priority['ID'] ? 'checked="checked"':'' ?>>
<label for="radio<?php echo $priority['ID']; ?>"><?php echo $priority['NAME']; ?></label>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div class="input-group date" id="datetimepicker6">
<span class="input-group-addon datepickerbutton">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input type="text" class="form-control" name="data" id="da" value="<?=$saved_data?>" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-remove"></span>
</span>
</div>
function autoInsertDate() {
let d = $('input[name=priority]:checked').val();
let days = d.split(',')[1];
let h = days * 24;
let currentDate = new Date();
var monthes = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
currentDate.setMilliseconds(h * 60 * 60 * 1000);
let year = currentDate.getFullYear();
let month = monthes[currentDate.getMonth()];
let day = currentDate.getDate();
let hour = currentDate.getHours();
let minutes = (currentDate.getMinutes() < 10) ? '0' + currentDate.getMinutes() : currentDate.getMinutes();
let time = day + '.' + month + '.' + year + ' ' + hour + ':' + minutes;
document.getElementById('da').value = time;
}
<select id="direct">
<option value="">- выберите направление -</option>
<?php if (is_array($directions)): ?>
<?php foreach ($directions as $direction): ?>
<option value="<?=$direction['ID']?>">
<?php echo $direction['NAME']; ?>
</option>
<?php endforeach; ?>
<?php endif; ?>
</select>
<select id="modules">
<option value="">- выберите модуль -</option>
</select>
$(document).on('change','#direct',function(){
let id = document.getElementById("direct").value;
$.getJSON("ajax", {id}, function (data) {
$.each(data, function (index, item) {
$("#modules").append('<option value ="'+item.ID+'">'+item.NAME+'</option>');
});
});
});
2. Как указал Дмитрий Беляев выше, а если ошибочно выбран option?