使用带有特定日期的select选项的Jquery日期选择器
这是演示 这是我的密码使用带有特定日期的select选项的Jquery日期选择器,jquery,jquery-ui-datepicker,Jquery,Jquery Ui Datepicker,这是演示 这是我的密码 <script> $(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'MM d, yy' }); $( "#datepicker2" ).datepicker({ cha
<script>
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
$( "#datepicker2" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
});
</script>
<li><label for="billing_cycle">Billing</label>
<select name="billing_cycle" >
<option >monthly</option>
<option >6 months (5% off)</option>
<option >12 months</option>
每次更改计费周期,从计费日期开始,过期日期也将更改
<script>
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy',
altField: "#datepicker2",
altFormat: 'MM d, yy'
});
$( "#datepicker2" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
var updateExpDate = function(monthToAdd) {
var now = new Date($('#datepicker').val());
monthToAdd = parseInt(monthToAdd);
var a = new Date(now).setMonth(now.getMonth() + monthToAdd);
var exp_date = new Date(a);
$('#datepicker2').datepicker('setDate', exp_date);
};
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
$("#datepicker2").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
$("#billing_cycle").on('change', function() {
updateExpDate($(this).val());
});
$('#datepicker').on('change', function() {
updateExpDate($('#billing_cycle').val());
});
});
有效期是否必须是日期选择器?我想是的。我只想编辑到期日,如果到期日是错误的,例如,一位客户抱怨他/她的到期时间早于到期时间。我的问题是,当我将计费周期更改为每月或从计费日期开始的6个月或12个月时,将如何更改到期日期。如果更改日期是例如2012年8月10日,则如果我将计费周期更改为每月,则到期时间将更改为2012年9月10日,如果是6个月,则到期日为2012年2月10日,如果是12个月,则到期日为2013年8月10日
<script>
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy',
altField: "#datepicker2",
altFormat: 'MM d, yy'
});
$( "#datepicker2" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
var updateExpDate = function(monthToAdd) {
var now = new Date($('#datepicker').val());
monthToAdd = parseInt(monthToAdd);
var a = new Date(now).setMonth(now.getMonth() + monthToAdd);
var exp_date = new Date(a);
$('#datepicker2').datepicker('setDate', exp_date);
};
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
$("#datepicker2").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM d, yy'
});
$("#billing_cycle").on('change', function() {
updateExpDate($(this).val());
});
$('#datepicker').on('change', function() {
updateExpDate($('#billing_cycle').val());
});
});