Jojoxx.net logotyp

 

 

Användare ikonAnvändare
Besökare just nu: 77
Snabblänkar ikonSnabblänkar
JavaScript-arkivet
Perl
FAQ

Sök på Jojoxx.net


Månadskalender

Exempel

Kod


<form name="myForm">
<select name="month">
<option value="Jan">Januari</option>
<option value="Feb">Februari</option>
<option value="Mar">Mars</option>
<option value="Apr">April</option>
<option value="May">Maj</option>
<option value="Jun">Juni</option>
<option value="Jul">Juli</option>
<option value="Aug">Augusti</option>
<option value="Sep">September</option>
<option value="Oct">Oktober</option>
<option value="Nov">Novmeber</option>
<option value="Dec">December</option>
</select>
<input type="button" onClick="this.form.year.value--" value=" - ">
<input type="text" value="2000" name="year" size=5>
<input type="button" onClick="this.form.year.value++" value=" + ">
<input type="button" value="Visa kalender" onClick="ViewCalender(this.form.month.options[this.form.month.selectedIndex].value, this.form.year.value)">
</form>
<script type="text/javascript">
/* Detta script finns att hämta på http://www.jojoxx.net och
   får användas fritt så länge som dessa rader står kvar. */

// Version 1.1

var now = new Date();
document.myForm.month.selectedIndex=now.getMonth();
if(navigator.appName=="Netscape"){
	document.myForm.year.value=now.getYear()+1900;
} else {
	document.myForm.year.value=now.getYear();
}
function ViewCalender(month, year){
	var date = new Date(month + " 1 00:00:01 " + year);
	var days = new Array("Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag");
	var months = new Array("Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December");
    var nrdays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	if (year / 4 == Math.floor(year / 4)) nrdays[1] = 29
	day = date.getDay();
	mon = date.getMonth();
	var daycount = 0 - day;
	var calender = window.open("","","toolbar=no,location=no,directories=no,status=no,menubar=no,width=500,height=240");
	with(calender.document){
		open();
		write("<html>\n<head>\<title>Jojoxx kalender</title>\n<body bgcolor=white>\n");
		write("<table border=0>\n<tr><td colspan=7><big>" + months[mon] + " " + year +"</big></td></tr>\n<tr>\n");
		for(n=0; n<7; n++){
			write("<td width=70>" + days[n] + "</td>");
		}
		write("\n</tr>\n");
		for(y=0; y<6; y++){
			write("<tr>");
			for(x=0; x<7; x++){
				daycount++
				if (x == 0) { col="red" } else { col ="#eeeeee" } 
				if (daycount > 0 && daycount <= nrdays[mon]){
					write("<td bgcolor='" + col + "'>" + daycount + "</td>");
				} else {
					write("<td bgcolor='" + col + "'> </td>");
				}
			}
			write("</tr>\n");
			if (daycount >= nrdays[mon]) y=6;
		}
		write("</table>\n</body>\n</html>\n");
		close();
	}
}
</script>

Kommentar

Bara att klippa och klistra.

,