views:

6

answers:

0

Hi All I'm working with jquery UI Datepicker. I have some code which is sending data to an ecommerece patform (Foxycart) I've added some code to highlight only certain (delivery days) and its clashing with the original datpicker code. can anyone see wuat the problem is?

link:

Example

Original code:

$(function() {
    $(".datepicker").datepicker({
      dateFormat: 'yy-mm-dd',
      onClose: function(dateText, inpt) { updateDates(dateText, inpt.id); }
    });




    jQuery(".datepicker").each(function() {
      if($(this).val() != "") {
      updateDates($(this).val(), $(this).attr("id"));
  }
    });

});



function updateDates(dateString, inputid) {
alterInput = jQuery("#"+inputid);
alterLink = jQuery("a#link_"+inputid);
pattern_qty = /(?:(?:&|\?){1}date=)((?:[0-9\-])*)/;

href = alterLink.attr("href");
newDate = (dateString == "") ? "" : "&date="+dateString;
if ( pattern_qty.test(href) ) {
  prefix = pattern_qty.exec(href); 
  newHref = href.replace(prefix[0], newDate);
  alterLink.attr("href", newHref);
} else {
  alterLink.attr("href", href + newDate);
}

}

function fc_PreProcess(oData, oID) { alterID = jQuery("#"+oID).attr("id").split("_")[1]; alterInput = jQuery("#"+alterID); if(jQuery(alterInput).val() == "") { alert('You need to choose a delivery date before adding a box'); return false; } else { return true; } }

});


Code with calendar highlighter:

$(function() {
    $(".datepicker").datepicker({
      dateFormat: 'yy-mm-dd',
      onClose: function(dateText, inpt) { updateDates(dateText, inpt.id); }
    });




    jQuery(".datepicker").each(function() {
      if($(this).val() != "") {
      updateDates($(this).val(), $(this).attr("id"));
  }
    });

});



function updateDates(dateString, inputid) {
alterInput = jQuery("#"+inputid);
alterLink = jQuery("a#link_"+inputid);
pattern_qty = /(?:(?:&|\?){1}date=)((?:[0-9\-])*)/;

href = alterLink.attr("href");
newDate = (dateString == "") ? "" : "&date="+dateString;
if ( pattern_qty.test(href) ) {
  prefix = pattern_qty.exec(href); 
  newHref = href.replace(prefix[0], newDate);
  alterLink.attr("href", newHref);
} else {
  alterLink.attr("href", href + newDate);
}

}

function fc_PreProcess(oData, oID) { alterID = jQuery("#"+oID).attr("id").split("_")[1]; alterInput = jQuery("#"+alterID); if(jQuery(alterInput).val() == "") { alert('You need to choose a delivery date before adding a box'); return false; } else { return true; } }

$(".datepicker").datepicker({
    beforeShowDay: function(date) {
        var day = date.getDay();
        return [(day != 0 && day != 1 && day != 3 && day != 4 && day != 6), ''];
    }

});

Thanks in advance