i have calendar code , but it has bog in it . can someone help me fix it .
i have datepicker ... i want it to take dates as "dd.mm.yy" but it takes them as "mm.dd.yy"
first part of the script is bugged ... but im new in java and i cant fix it ...
$(function() { var disabledDaysRange = [["15.04.2011 to 15.05.2011"]]; function disableRangeOfDays(d) { for(var i = 0; i < disabledDaysRange.length; i++) { if($.isArray(disabledDaysRange[i])) { for(var j = 0; j < disabledDaysRange[i].length; j++) { var r = disabledDaysRange[i][j].split(" to "); r[0] = r[0].split("."); r[1] = r[1].split("."); if(new Date(r[0][2], (r[0][0]-1), r[0][1]) <= d && d <= new Date(r[1][2], (r[1][0]-1), r[1][1])) { ///i think maybe that part is bugged return [false]; } } }else{ if(( d.getDate()+ '.' + (d.getMonth()+1) + '.' + d.getFullYear()) == disabledDaysRange[i]) { return [false]; } } } return [true]; } var dates = $( "#from, #to" ).datepicker({ defaultDate: "+1w", dateFormat: 'dd.mm.yy', beforeShowDay: disableRangeOfDays, changeMonth: true, numberOfMonths: 3, onSelect: function( selectedDate ) { var option = this.id == "from" ? "minDate" : "maxDate", instance = $( this ).data( "datepicker" ); date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings ); dates.not( this ).datepicker( "option", option, date ); } }); });
PHP Code:
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script src="/jquery.ui.datepicker-et.js"
type="text/javascript"></script>
<form name="all1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<script>
$(function() {
var disabledDaysRange = [["03.04.2011 to 04.05.2011"]];
function disableRangeOfDays(d) {
for(var i = 0; i < disabledDaysRange.length; i++) {
if($.isArray(disabledDaysRange[i])) {
for(var j = 0; j < disabledDaysRange[i].length; j++) {
var r = disabledDaysRange[i][j].split(" to ");
r[0] = r[0].split(".");
r[1] = r[1].split(".");
if(new Date(r[0][2], (r[0][0]-1), r[0][1]) <= d && d <= new Date(r[1][2], (r[1][0]-1), r[1][1])) {
return [false];
}
}
}else{
if(( d.getDate()+ '.' + (d.getMonth()+1) + '.' + d.getFullYear()) == disabledDaysRange[i]) {
return [false];
}
}
}
return [true];
}
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
dateFormat: 'dd.mm.yy',
beforeShowDay: disableRangeOfDays,
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" );
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>
<div class="demo">
<label for="from"><b>Algus</b></label>
<input type="text" id="from" name="from"/>
<label for="to"><b>Lõpp</b></label>
<input type="text" id="to" name="to"/>
<?php
include("connect_db.php");
if(isset($_POST['submit']))
{
if ($_POST["from"] == 0)
{
echo '<tr><td align="center"><h4>Palun valige algus kuupäev!</h4></td></tr>';
}
else
{
if ($_POST["to"] == 0)
{
echo '<tr><td align="center"><h4>Palun valige lõpu kuupäev!</h4></td></tr>';
}
else
{
}
}
}
@$alg = $_POST['from'];
@$lop = $_POST['to'];
echo "<b><h3>$alg - $lop</h3></b>";
?>
<?php
if(isset($_POST['submit']))
{
$january = new DateTime("$alg");
$february = new DateTime("$lop");
$interval = $february->diff($january);
echo $interval->format('<b><h3>%m Kuid, %d Päevasid</h3></b>');
}
?>
<table border='0' width='250'>
<tr><td align="right"><input type="submit" name="submit" value="Edasi" /></td></tr>
</form>
</table>
</head>
<body style="font-size:62.5%;">
<div type="text" id="datepicker"></div>
</body>
</html>