javascript - Why are the radio buttons resetting when clicking on this jquery datepicker -
here jquery datepicker:
$.fn.dcalendarpicker = function(opts){ return $(this).each(function(){ var = $(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(); }); }); }
here php/html:
echo "<fieldset>"; echo "<h5>select 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 atleast 1 week today)</label>"; echo "(mm/dd/yyyy) <input id =\"calendar-demo\" type=\"text\" name=\"delivery_start_date\" value=\"".$delivery_date."\"/><br>"; echo "</fieldset>";
for reason every time click date input field in fieldset above, , select date jquery datepicker dropdown, weekly/monthly radio button selection reset, , have no idea why...
i figured out...i had label tag unclosed:
echo "<label>select weekly or monthly deliveries: <label><br>";
should be:
echo "<label>select weekly or monthly deliveries: </label><br>";
Comments
Post a Comment