Календар

NevarMore

Registered
Някой може ли да ми направи календар като цъкнеш на дата и да ти маркира датата и да ти извежда в текстово поле или като alert(); адреса му по PHP (11th April, 2014) или да ми даде основния код за един календар пак от там да си го развия ....

Мерси ! :)
 
http://jqueryui.com/datepicker/ :idea: :idea: :?:

edit: това е примера от сайта, в случай, че не си го видял
HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
:?:
 
Имах едно домашно да направя календар...
ето ти и кода може да ти помогне

PHP:
	$intYear = ( !isset($_GET['year']) ) ? date("Y") : $_GET['year'];
	$intMonth = ( !isset($_GET['month']) ) ? (int)date("m") : $_GET['month'];
	$intDay = ( !isset($_GET['day']) ) ? date("d") : $_GET['day'];
	$strToday = date( "Y-m-d" );

	$strDate = $intYear . "-" . $intMonth . "-" . $intDay;
	$arrDate = date_parse($strDate);
	
	function get_rebild_url($name, $value)
	{
		if( preg_match("/\?/", $_SERVER['REQUEST_URI']) )
		{
			$url = explode('?', $_SERVER['REQUEST_URI']);
			parse_str($url['1'], $data);
		}

		$data[$name] = $value;
		$url = '?' . http_build_query($data);
		return $url;
	}

	function month_name($int)
	{
		$arrNember['1'] = 'Януари';
		$arrNember['2'] = 'Февруари';
		$arrNember['3'] = 'Март';
		$arrNember['4'] = 'Април';
		$arrNember['5'] = 'Май';
		$arrNember['6'] = 'Юни';
		$arrNember['7'] = 'Юли';
		$arrNember['8'] = 'Август';
		$arrNember['9'] = 'Септември';
		$arrNember['10'] = 'Октомври';
		$arrNember['11'] = 'Ноември';
		$arrNember['12'] = 'Декември';
		return $arrNember[$int];
	}
	$sub_li = '<ul>';
	$month_while = 1;
	while( $month_while <= 12 )
	{
		$image = ( $month_while == 12 ) ? "end" : "middle";
		$class = ( $month_while == $intMonth ) ? "active" : "";
		$sub_li .= "<li style='background: url(". $image .".gif) no-repeat;'><a href='". get_rebild_url("month", $month_while ) ."' class=$class>". month_name($month_while) ."</a></li>";
		$month_while++;
	}
	$sub_li .= '</ul>';

	$li = "<ul>";
	$year_while = 1;
	$year_while_total = 12;
	while( $year_while <= $year_while_total )
	{
		
		
		$year_while_ceil = $year_while_total / 2;
		
		if( $year_while < $year_while_ceil )
		{
			$image = "middle";
			

			$year_while_length = ceil($year_while_ceil) - $year_while;
			$li .= "<li style='background: url(". $image .".gif) no-repeat;' ><a href='" . get_rebild_url("year", $intYear - $year_while_length ) . "'>" . ( $intYear - $year_while_length ) . "г." . "</a></li>";
		}
		else if( $year_while > ceil($year_while_ceil) )
		{
			$year_while_length = $year_while - ceil($year_while_ceil);

			$image = "middle";
			$image = ( $year_while == $year_while_total ) ? "end" : "middle";
			$li .= "<li style='background: url(". $image .".gif) no-repeat;' ><a href='" . get_rebild_url("year", $intYear + $year_while_length ) . "'>" . ( $intYear + $year_while_length ) . "г." . "</a></li>";
		}
		else
		{	
			$image = "end";
			$li .= "<li style='background: url(". $image .".gif) no-repeat; color: #ff0000; ' ><a href='" . get_rebild_url("year", $intYear ) . "' class=active >" . ( $intYear ) . "г." . "</a>${sub_li}</li>";

		}

		$year_while++;
	}
	$li .= '</ul>';


	$switch =	"<div class='subnav' >";
	$switch .=		"<ul>";
	$switch .=			"<li class='first' ><b>Календар</b></li>";
	$switch .=			"<li>".$li."</li>";
	$switch .=		"</ul>";
	$switch .=	"</div>";

	$switch .=	"<div class='content' style=''>";

	$length_year = (date("L", strtotime($intYear . "-" . $intMonth)) == 1 ) ? "( Високосна !)" : "";

	$switch .= "<b> " . month_name($intMonth) . " " . $intYear . $length_year . "г.</b>";

	
	$switch .= "<table border=1 class='calendar' >";

	$switch .= 	"<tr>";
	$switch .= 		"<th>Понеделник</th>";
	$switch .= 		"<th>Вторник</th>";
	$switch .= 		"<th>Сряда</th>";
	$switch .= 		"<th>Четвъртък</th>";
	$switch .= 		"<th>Петък</th>";
	$switch .= 		"<th>Събота</th>";
	$switch .= 		"<th>Неделя</th>";
	$switch .= 	"</tr>";


	$intDay_of_month_total = date("t", strtotime( $intYear . "-" . $intMonth . "-". "01" ));
	$intDay_of_month = 1;
	$indDay_of_month_while = 1;
	while ( $intDay_of_month <= $intDay_of_month_total )
	{
		$switch .= "<tr>";
		for($d=1; $d<=7; $d++)
		{

			if( $d != date("N", strtotime($intYear . "-" . $intMonth . "-" . $intDay_of_month) ) || $intDay_of_month > $intDay_of_month_total )
			{
				$class = ($d >= 6) ? "week" : "";
				$switch .= 	"<td class=". $class ."></td>";
			}
			else
			{


				$strToday_of_calendar = date( "Y-m-d", strtotime( $intYear . "-" . $intMonth . "-" . $intDay_of_month ) );

				if( $strToday_of_calendar == $strToday  ) 
				{
					$id = "today";
				}
				else { 
					$id = "";
				}

				$class = ( $d >= 6 ) ? "week" : "";


				$switch .= 	"<td class=". $class ." id=". $id .">". $intDay_of_month . "</td>";
				$intDay_of_month++;
			}

				$indDay_of_month_while++;
		}
		$switch .= "</tr>";
	}

	$switch .= "</table>";

	$switch .=	"</div>";


	echo $switch;

писан е преди бая време..., само му барни стиловете има си класове всичко. страницирането е доста удобно...
 

Back
Горе