[英]Why are the radio buttons resetting when clicking on this jquery 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下拉列表中選擇一個日期,每周/每月單選按鈕選擇都會重置,我也不知道為什么...
我想通了...我沒有關閉標簽:
echo "<label>Select weekly or monthly deliveries: <label><br>";
應該:
echo "<label>Select weekly or monthly deliveries: </label><br>";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.