473,387 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calendar help

I am creating a calendar with JavaScript. I want to be able to put
date and time in an array and have a calendar display properly with 7
columns. I am stuck at this point. Any help would be appreciated. I
hope I formatted it properly for this group.

var month="October 2003";

var ct = 0;

var dt=new Array();
dt[1]=new Array("1,5:15-8");
dt[2]=new Array("2,5-8");
dt[3]=new Array("3,5-8");
dt[4]=new Array("4,1-4:45");
dt[5]=new Array("5,1-3");
dt[6]=new Array("6,4:45-6:45");
dt[7]=new Array("7,4:45-6:45");
dt[8]=new Array("8,none");
dt[9]=new Array("9,4:45-6:45");
dt[10]=new Array("10,3:30-6:30");
dt[11]=new Array("11,1-3");
dt[12]=new Array("12,1-3");
dt[13]=new Array("13,4:45-6:45");
dt[14]=new Array("14,4:45-6:45");
dt[15]=new Array("15,none");
dt[16]=new Array("16,none");
dt[17]=new Array("17,4:45-6:45");
dt[18]=new Array("18,NOICE");
dt[19]=new Array("19,1-3");
dt[20]=new Array("20,4:45-6:45");
dt[21]=new Array("21,4:45-6:45");
dt[22]=new Array("22,none");
dt[23]=new Array("23,none");
dt[24]=new Array("24,12-2");
dt[25]=new Array("25,1-3");
dt[26]=new Array("26,1-3");
dt[27]=new Array("27,4:30-6:45");
dt[28]=new Array("28,4:30-6:45");
dt[29]=new Array("29,NO ICE");
dt[30]=new Array("30,NO ICE");
dt[31]=new Array("31,NO ICE");
document.write('<center><table border width=530',
' bgcolor="ffffff">');
document.write('<tr><td colspan=7><h1 align=center>'
+ month + ' Public Skating Times<\/h1><\/td><\/tr>');

document.write('<tr align=center>');
document.write('<td><b>Sunday<\/b><\/td>');
document.write('<td><b>Monday<\/b><\/td>');
document.write('<td><b>Tuesday<\/b><\/td>');
document.write('<td><b>Wednesday<\/b><\/td>');
document.write('<td><b>Thursday<\/b><\/td>');
document.write('<td><b>Friday<\/b><\/td>');
document.write('<td><b>Saturday<\/b><\/td><\/tr>');

for (var i=dt.length-1;i>=0;i--)
{
if (ct <= 7) {
if (ct = 0) {
document.write('<td valign=top colspan=' +
ct + '> + dt[i][0] + '<br>' + dt[i][1] +
'<\/td>');
}
document.write('<td valign=top>' + dt[i][0] +
'<br>' + dt[i][1] + '<\/td>');
ct = ct + 1
if (ct = 7) {
document.write('<\/tr><tr valign=top align=right>');
ct = 1;
}
}
document.write('<\/tr><\/table><br><b>NOTE:',
'All times are PM unless noted.<\/b><\/center>');
Jul 20 '05 #1
6 1934
JRS: In article <aa******************************@news.teranews.co m>,
seen in news:comp.lang.javascript, Treetop <tr*****@netfront.net> posted
at Wed, 8 Oct 2003 16:28:04 :-
I am creating a calendar with JavaScript. I want to be able to put
date and time in an array and have a calendar display properly with 7
columns. I am stuck at this point. Any help would be appreciated. I
hope I formatted it properly for this group.

var month="October 2003";

var ct = 0;

var dt=new Array();
dt[1]=new Array("1,5:15-8");
dt[2]=new Array("2,5-8");
dt[3]=new Array("3,5-8");
dt[4]=new Array("4,1-4:45");


There is no real need to store day-of-month in an array indexed by day-
of-month.

This line is wrong :
ct + '> + dt[i][0] + '<br>' + dt[i][1] + '

and in that region you need to count and adjust your } to match { - add
one after ct = 1; ?

i>=0 should be i>0 .

That at least gets you a Table showing.

if ( = ) should be if ( == ), twice.

That gets a multi-column table.

In the many new Array lines, put the first " after the ' .
Your move.
I think you write too much code at once, before testing. since you can
view pages locally, you should test after every step
You could start with the code of <URL:http://www.merlyn.demon.co.uk/js-
date6.htm#DP> and replace LZ(Q) by dt[Q], using that array dt. Titivate
the layout; you'll need to pad the entries to constant width, and/or
perhaps change the buttons to table elements.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #2
I got the Calendar working and is at
http://www.tricityarena.com/skating_open.html

in case anyone wanted to see it. The JavaScript code is at
http://www.tricityarena.com/openskating.js
In order to diplay the dates in the correct order I had to change the
array from

dt[31]=new Array("31","NO ICE");
to
dt[1]=new Array("31","NO ICE");

Instead of the date corrisponding to the dt number (don't know proper
term) I had to reverse the order for it to display properly.

I have a question on this. I can comment out the line dt[1... if I
don't need the date. Will this mess up how it displays on non
Netscape / IE browsers? For example If I have a month with only 30
days I can comment out the line with the 31st date in it, however the
dt number (don't know proper term) of 1 will not be displayed. The
Array will start with 2 instead of 1. I hope my question makes sense.
Jul 20 '05 #3
JRS: In article <cf******************************@news.teranews.co m>,
seen in news:comp.lang.javascript, Treetop <tr*****@netfront.net> posted
at Thu, 9 Oct 2003 16:55:13 :-

I have a question on this. I can comment out the line dt[1... if I
don't need the date. Will this mess up how it displays on non
Netscape / IE browsers? For example If I have a month with only 30
days I can comment out the line with the 31st date in it, however the
dt number (don't know proper term) of 1 will not be displayed. The
Array will start with 2 instead of 1. I hope my question makes sense.


An Array can have "missing" elements; AFAICS, an Array is basically an
Object with some added methods and a feeling of kinship with the
linearly-stored arrays of traditional languages. You will then need to
allow for the possibility of looking at an element which is undefined.
But var U gives a U which is equally undefined.

One can use an Object instead, with data like :

Events =
{ Y2003:{M10:{D26:"Summer Time Off"}, M03:{D30:'Summer Time On'}},
Y2004:{M04:{D11:"Easter Sunday"}} }

Yearly =
{ M04:{D01:"All Fools Day"}, M12:{D25:'Christmas Day'},
M10:{D21:"Trafalgar Day"}, M06:{D18:'Waterloo Day'} }

<URL:http://www.merlyn.demon.co.uk/js-date6.htm#EP>, still changing, is
an Event Picker using such; it does not yet? allow for more than one
entry per day in either Object.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #4
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
An Array can have "missing" elements; AFAICS, an Array is basically an
Object with some added methods and a feeling of kinship with the
linearly-stored arrays of traditional languages.


Indeed. A Javascript array is a Javascript object with extra
functionality. There are some extra methods in Array.prototype, but
they can all be used on other objects too if you want it.

The one thing that makes arrays unique is the length property, which
is linked to the properties with names that can be represented as 32
bit integers.

As an invariant, the value of the length property must be larger than
all integer properties of the array. If you create a new integer named
property that is larger than the length property, the length property
is increased. If you decrease the length property, some integer named
properties are deleted. That is all that makes an array special.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5
JRS: In article <wu**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Fri, 10 Oct 2003 02:56:59 :-
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
An Array can have "missing" elements; AFAICS, an Array is basically an
Object with some added methods and a feeling of kinship with the
linearly-stored arrays of traditional languages.
Indeed. A Javascript array is a Javascript object with extra
functionality. There are some extra methods in Array.prototype, but
they can all be used on other objects too if you want it.


I don't follow - does that, for example, apply to the Array method
reverse, which seems inapplicable to Objects with general names
"inside"?

The one thing that makes arrays unique is the length property

...
<URL:http://www.merlyn.demon.co.uk/js-date6.htm#EP>, still changing, now
handles multiple entries per day.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #6
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
I don't follow - does that, for example, apply to the Array method
reverse, which seems inapplicable to Objects with general names
"inside"?


It applies to any object with a property called "length" and zero or
more properties whose names are representable as 32-bit integers.

var o = {"0":"a","2":"b","3":"c","10":"z",length:4};
Array.prototype.reverse.call(o);
alert(Array.prototype.join.call(o,"/") + " : " + o[10]);

By design, most array properties are general, and can be applied to
any object. The only assume the existence of a length property, and
they operate on the integer numbered properties smaller than the
length.

That means that they are applicaply to arrays, HTML collections
(except that they are not mutable), etc. They don't touch the
non-integer properties.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
0
by: GFro | last post by:
I have a calendar page that returns a date to a textbox on the parent page. It is returning the wrong format on the deployment server. On the development server the calendar returns to textbox in...
3
by: Peter | last post by:
Is there anyway to make the System.Web.UI.WebControls.Calendar to display only Month Name and Year, like: January, 2006 February, 2006 ..... .... .... ....
6
by: Mike9900 | last post by:
Hello, I want to view the calendar in another culture, for example let it show in Arabic. I use this code in the Main, but the calendar is still in the same culture: CultureInfo sa = new...
3
by: brianwolters | last post by:
Hello, I have a calendar and a textbox right below it on my webpage. I need help with creating some code to display information about the date the user clicked in the text box below it. For...
12
cassbiz
by: cassbiz | last post by:
I downloaded this calendar off the web and am trying have it show twice, once as calendar.php and the second time as calendar1.php I need the visitor to be able to select a beginning date and an...
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
7
by: William (Tamarside) | last post by:
Please, if you have the time and knowledge to help me I'd truly appreciate it! I need to build a calendar page that displays available/unavailable info from a DB and colour a cell according to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.