这是datepicker的jquery:
$.fn.dcalendarpicker = function(opts){
return $(this).each(function(){
var that = $(this);
var cal = $('<table class="calendar"></table>'), hovered = false, selectedDate = false;
that.wrap($('<div class="datepicker" style="display:inline-block;position:relative;"></div>'));
cal.css({
position:'absolute',
left:0, display:'none',
'box-shadow':'0 4px 6px 1px rgba(0, 0, 0, 0.14)',
width:'230px',
}).appendTo(that.parent());
if(opts){
opts.mode = 'datepicker';
cal.dcalendar(opts);
}
else
cal.dcalendar({mode: 'datepicker'});
cal.hover(function(){
hovered = true;
}, function(){
hovered = false;
}).on('click', function(){
// SCRIPT MOD - skip radio buttons
if(!selectedDate)
that.focus();
else {
selectedDate = false;
$(this).hide();
}
}).on('selectdate', function(e){
that.val(e.date).trigger('onchange');
that.trigger($.Event('dateselected',{date: e.date, elem: that}));
selectedDate = true;
});
that.on('keydown', function(e){ if(e.which) return false; })
.on('focus', function(){
$('.datepicker').find('.calendar').not(cal).hide();
cal.show();
})
.on('blur', function(){ if(!hovered) cal.hide(); });
});
}
这是php / html:
echo "<fieldset>";
echo "<h5>Select Your Delivery Date: </h5>";
echo "<label class=\"error_label\">".$error_juice_delivery."</label>";
echo "<label>Select weekly or monthly deliveries: <label><br>";
$type_1 = $type_2 = '';
if($delivery_type === '1') $type_1 = 'checked';
else $type_2 = 'checked';
echo "Weekly <input type=\"radio\" name=\"delivery_date_type\" value=\"1\" $type_1 /><br>";
echo "Monthly <input type=\"radio\" name=\"delivery_date_type\" value=\"2\" $type_2 /><br>";
echo "<br><label>Type in delivery start date(has to be atleast one week from today)</label>";
echo "(mm/dd/yyyy) <input id =\"calendar-demo\" type=\"text\" name=\"delivery_start_date\" value=\"".$delivery_date."\"/><br>";
echo "</fieldset>";
出于某种原因每次我点击上面字段集中的日期输入字段,并从jquery datepicker下拉列表中选择一个日期,每周/每月单选按钮选择被重置,我不明白为什么......
答案 0 :(得分:0)
我想通了......我的标签标签未公开:
echo "<label>Select weekly or monthly deliveries: <label><br>";
应该是:
echo "<label>Select weekly or monthly deliveries: </label><br>";