我有一个during
下拉列表,并且有三个字段3 months, 6 months & 1 year
。然后我们有日期from
和to
。当我选择日期From
时,则To
中的日期将根据选定的持续时间增加。
我尝试了什么:-
/*$('.datePicker').datetimepicker({
timepicker: false,
format: 'm/d/Y'
});
*/
$(document).ready(function () {
durationTermF();
function durationTermF() {
$('#durationTerm').on('change', function () {
var durationTerm = $(this).find('option:selected').text();
alert(durationTerm);
})
}
$('body').on ('blur', '.pcFrom',function () {
durationTermF();
var fromDate = $(this).val();
$('.pcTo').val(fromDate);
});
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://ethiomedical.ansitsdev.com/WebContent/plugins/datetimepicker/jquery.datetimepicker.css" />
<script src="http://ethiomedical.ansitsdev.com/WebContent/plugins/datetimepicker/jquery.datetimepicker.js"></script>
<div class="container">
<br>
<div class="col-md-4">
<div class="form-group">
<label>Duration</label>
<select class="form-control" id="durationTerm">
<option>select</option>
<option value="15">3 month</option>
<option value="16">6 month</option>
<option value="17">1 year</option>
</select>
</div>
<div class="form-group">
<label>From</label>
<input type="text" class="form-control datePicker pcFrom">
</div>
<div class="form-group">
<label>To</label>
<input type="text" class="form-control pcTo">
</div>
</div>
</div>