/    Sign up×
Community /Pin to ProfileBookmark

looking for javascript calendar with no images

Hello,

I am looking for a javascript calendar for my date input field that has no images in it. When I take a look at most calendars online, they have images for the buttons. I was looking for something that just had <, <<, >>, > instead.

Does anyone have something like this?

Thank,

Derek

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERAug 29.2013 — Something like this? ...

HTML section
<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;Calendar&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;meta name="viewport" content="width=device-width"&gt;
&lt;meta name="viewport" content="initial-scale=1.0, user-scalable=yes"/&gt;

&lt;style type="text/css"&gt;
@media print { body { font-size: 16pt } }
@media screen { body { font-size: 16px } }
@media handheld { body { font-size: 24px } }
@media screen, print { body { line-height: 1.2 } }

div.cal {
border: 1px solid blue;
display: none;
}
&lt;/style&gt;
&lt;script type="text/javascript" src="cal.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
var MonthsYears = [ [{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}],
[{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}],
[{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}], [{Month:0,Year:0}] ];
var month = 0; var year = 0;
var CalSize = 1; // allows 1..12;
var CalVert = 1; // allows 1,2,3,4,6,12 as sizes
var CalWide = 4;
// var CalWide = CalSize / CalVert;

Initialize();

function InitMonth() {
for (i=0; i&lt;12; i++) { document.getElementById('cal'+i).style.display = 'none'; }
for (i=0; i&lt;CalSize; i++) { document.getElementById('cal'+i).style.display = 'block'; }
}
function InitYear() {
for (i=0; i&lt;12; i++) { document.getElementById('cal'+i).style.display = 'block'; }
}

function Initialize() {
var now = new Date(); month = now.getMonth(); year = now.getFullYear();
for (i=0; i&lt;12; i++) {
MonthsYears[i].Month = month;
MonthsYears[i].Year = year;
}
Normalize(0);
}
function Normalize(amt) {
// Array return idea from:
// http://www.webdeveloper.com/forum/showthread.php?t=167956
var arr = new Array();
for (i=0; i&lt;12; i++) {
MonthsYears[i].Month = month+i;
MonthsYears[i].Year = year;
arr = Adjust(amt,MonthsYears[i].Month,MonthsYears[i].Year);
MonthsYears[i].Month = arr.AMonth;
MonthsYears[i].Year = arr.AYear;
}
}
function Adjust(Direction,M,Y) {
M += Direction;
if (M &lt; 0) { M += 12; Y = Y-1; }
if (M &gt; 11) { M -= 12; Y = Y+1; }
return {AMonth:M, AYear:Y};
}
function Redisplay() {
var str = '';
var calID = '';
for (i=0; i&lt;12; i++ ) {
calID = 'cal'+i;
str = displayCalendar(MonthsYears[i].Month+1,MonthsYears[i].Year);
document.getElementById(calID).innerHTML = str;
}
}
function AdjustMonthYear(Mamt,Yamt) {
var arr = new Array();
arr = Adjust(Mamt,month,year+Yamt);
month = arr.AMonth;
year = arr.AYear;
}
function prevMonthYear(Mamt,Yamt) { AdjustMonthYear(Mamt,Yamt); Normalize(0); Redisplay(); }
function nextMonthYear(Mamt,Yamt) { AdjustMonthYear(Mamt,Yamt); Normalize(0); Redisplay(); }

&lt;/script&gt;
&lt;/head&gt;
&lt;body onLoad="InitMonth()"&gt;
&lt;!-- could also InitYear() if desired --&gt;

&lt;script type="text/javascript"&gt;
var calID = ''; // CalWide = CalSize / CalVert;
var str = '&lt;table border="0"&gt;';
for (i=0; i&lt;12; i++) {
calID = 'cal'+i;
if ((i % CalWide) == 0) { str += '&lt;tr&gt;'; }
str += '&lt;td&gt;&lt;div id="'+calID+'" class="cal"&gt;'
str += displayCalendar(MonthsYears[0].Month+1,MonthsYears[0].Year)+'&lt;/div&gt;&lt;/td&gt;';
}
str += '&lt;tr&gt;&lt;th&gt;';
str += '&lt;a href="#" onClick="InitMonth();Initialize();Redisplay();return false"&gt;Month&lt;/a&gt;';
str += ' / ';
str += '&lt;a href="#" onClick="InitYear();Redisplay();return false"&gt;Year&lt;/a&gt;';
str += '&lt;/th&gt;&lt;/tr&gt;';
str += '&lt;tr&gt;&lt;th&gt;';
str += '&lt;button onClick="prevMonthYear( 0,-1);return false;"&gt;&amp;lt;&amp;lt;&lt;/button&gt;';
str += '&lt;button onClick="prevMonthYear(-1, 0);return false;"&gt;&amp;lt;&lt;/button&gt;';
// str += '&lt;button onClick="Initialize();Redisplay();return false;"&gt;*&lt;/button&gt;';
str += '&lt;button onClick="nextMonthYear( 1, 0);return false;"&gt;&amp;gt;&lt;/button&gt;';
str += '&lt;button onClick="nextMonthYear( 0, 1);return false;"&gt;&amp;gt;&amp;gt;&lt;/button&gt;';
str += '&lt;/th&gt;&lt;/tr&gt;';

str += '&lt;/table&gt;';
document.write(str);
Redisplay();
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;


JS section
<i>
</i>// Calendar Display
var MonthOfYear = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];

function displayCalendar(month, year) { <br/>
month = parseInt(month);
month--; // adjustment when 'month' parameter passed as "1"..."12"
year = parseInt(year);
var i = 0;
var days = getDaysInMonth(month+1,year);
var firstOfMonth = new Date (year, month, 1);
var startingPos = firstOfMonth.getDay();
days += startingPos;
var page = '&lt;pre&gt; '+MonthOfYear[month]+' '+year;
page += "n Su Mo Tu We Th Fr Sa";
page += "n --------------------";
for (i = 0; i &lt; startingPos; i++) {
if ( i%7 == 0 ) page += "n ";
page += " ";
}
for (i = startingPos; i &lt; days; i++) {
if ( i%7 == 0 ) page += "n ";
// if (i-startingPos+1 &lt; 10) page += "0";
if (i-startingPos+1 &lt; 10) page += " ";
page += i-startingPos+1;
page += " ";
}
for (i=days; i&lt;42; i++) {
if ( i%7 == 0 ) page += "n ";
page += " ";
}
page += '&lt;/pre&gt;';
return page;
}
function getDaysInMonth(month,year) {
var days;
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) days=31;
else if (month==4 || month==6 || month==9 || month==11) days=30;
else if (month==2) {
if (isLeapYear(year)) { days=29; }
else { days=28; }
}
return (days);
}
function isLeapYear (Year) {
if (((Year % 4)==0) &amp;&amp; ((Year % 100)!=0) || ((Year % 400)==0)) { return (true); } else { return (false); }
}
Copy linkTweet thisAlerts:
@domiereavronauthorAug 30.2013 — This works pretty good. I didn't need the part that shows all the other months and now I am trying to have the numbers be inside a <td></td> or div to have a border or box like a calendar. I am trying to figure out if they click a date like july 1st, 2013 how I can get it to go inside an input field showing that what was selected. Ideally I have a text input field, when I click on it the calendar appears, they select a date and the calendar disappears and the date goes into the input field
Copy linkTweet thisAlerts:
@JMRKERAug 30.2013 — That's another level of complexity that you did not specify in your first post.

You should think through what it is that you want and design for that rather than try to add on at a later time. :rolleyes:

I only say this because too many times I have thought of some special feature I wanted to add to a simple bit of code,

only to find out that I had to start from scratch because of too many coding conflicts as I modified the simplified code. ?

See if this meets your needs. Note there is SOME similarity, but it is not just a straight line modification from simple to complex.

HTML section:
<i>
</i>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Quick Month Calendar&lt;/title&gt;

&lt;style type="text/css"&gt;
div.cal { width:225px; } /* border: 1px solid blue; } */
.date { cursor:pointer; font-size:0.9em; } /* cursor:default; } */
&lt;/style&gt;

&lt;script type="text/javascript" src="./cal.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
// Modified for: http://www.webdeveloper.com/forum/showthread.php?t=209904
// Modified again for: http://www.webdeveloper.com/forum/newreply.php?do=postreply&amp;t=283147

var now = new Date(); // normally use this
var monthM = now.getMonth()+1;
var yearM = now.getFullYear();

function Initialize() {
var now = new Date(); // normally use this
monthM = now.getMonth()+1; yearM = now.getFullYear();
monthC = monthM; yearC = yearM;
return '';
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="Initialize();CalendarRedisplay(monthM,yearM)"&gt;
&lt;input type="text" id="SelectedDate" value="" size="10"&gt;

&lt;table border="0"&gt;&lt;tr&gt;&lt;td&gt;
&lt;table border="0"&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;
&lt;div id="calM" class="cal"&gt;'
&lt;script type="text/javascript"&gt; CalendarRedisplay(monthM,yearM); &lt;/script&gt;
&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;



JS section:
<i>
</i>// Calendar Display (cal.js)

var MonthOfYear = ['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var DaysInMonth = ['',31,28,31,30,31,30,31,31,30,31,30,31];
var monthC = 0; var yearC = 0;

function CalendarRedisplay(M,Y) {
if (M &lt; 1) { M = 12; Y--; }
if (M &gt; 12) { M = 1; Y++; }
monthC = M; yearC = Y;
document.getElementById("calM").innerHTML = displayCalendar(M,Y);
}

function displayCalendar(month, year) {
month = parseInt(month);
year = parseInt(year);
var i = 0;
var days = getDaysInMonth(month,year);
var firstOfMonth = new Date (year, (month-1), 1);
var startingPos = firstOfMonth.getDay();
days += startingPos;
var page = '&lt;table border="1" width="100%"&gt;&lt;tr&gt;&lt;th colspan="7"&gt;';
page += '&lt;button onClick="CalendarRedisplay('+month+','+(year-1)+');return false"&gt;|&lt;/button&gt; ';
page += '&lt;button onClick="CalendarRedisplay('+(month-1)+','+year+');return false"&gt;&amp;lt;&lt;/button&gt; ';

page += '&lt;button onClick="CalendarRedisplay('+monthM+','+yearM+');return false;"&gt;';
page += MonthOfYear[month]+' '+year+'&lt;/button&gt;';

page += ' &lt;button onClick="CalendarRedisplay('+(month+1)+','+year+');return false"&gt;&amp;gt;&lt;/button&gt;';
page += ' &lt;button onClick="CalendarRedisplay('+month+','+(year+1)+');return false"&gt;|&lt;/button&gt;';
page += '&lt;/th&gt;&lt;/tr&gt;';

page += '&lt;tr&gt;&lt;th class="date"&gt;Su&lt;/th&gt;&lt;th class="date"&gt;Mo&lt;/th&gt;&lt;th class="date"&gt;Tu&lt;/th&gt;&lt;th class="date"&gt;';
page += 'We&lt;/th&gt;&lt;th class="date"&gt;Th&lt;/th&gt;&lt;th class="date"&gt;Fr&lt;/th&gt;&lt;th class="date"&gt;Sa&lt;/th&gt;&lt;/tr&gt;';
page += '&lt;tr&gt;'; <br/>
for (i = 0; i &lt; startingPos; i++) {
if ( i%7 == 0 ) page += "&lt;/tr&gt;&lt;tr&gt;";
page += '&lt;th&gt;&lt;span class="date"&gt;&amp;nbsp;&lt;/span&gt;&lt;/th&gt;';
}
for (i = startingPos; i &lt; days; i++) {
if ( i%7 == 0 ) page += "&lt;/tr&gt;&lt;tr&gt;";
page += '&lt;th&gt;&lt;span class="date"';
page += ' onclick="calAction('+"'"+pad(month)+'/'+pad(i-startingPos+1)+'/'+year+"'"+')"&gt;';
page += (i-startingPos+1) + '&lt;/span&gt;&lt;/th&gt;';
}
for (i=days; i&lt;42; i++) {
if ( i%7 == 0 ) page += "&lt;/tr&gt;&lt;tr&gt;";
page += "&lt;td&gt;&amp;nbsp;&lt;/td&gt;";
}
page += '&lt;/tr&gt;&lt;/table&gt;';
return page;
}

function getDaysInMonth(month,year) {
var days = DaysInMonth[month];
if ((month == 2) &amp;&amp; isLeapYear(year)) { days=29; }
return days;
}

function isLeapYear (Year) {
if (((Year % 4)==0) &amp;&amp; ((Year % 100)!=0) || ((Year % 400)==0)) { return (true); }
else { return (false); }
}

function pad(value) { return value=(value &lt; 10)?'0'+value:value; }

function calAction(info) { document.getElementById('SelectedDate').value = info; }

×

Success!

Help @domiereavron spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...