473,661 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><tabl e 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>Wednesd ay<\/b><\/td>');
document.write( '<td><b>Thursda y<\/b><\/td>');
document.write( '<td><b>Friday< \/b><\/td>');
document.write( '<td><b>Saturda y<\/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>NO TE:',
'All times are PM unless noted.<\/b><\/center>');
Jul 20 '05 #1
6 1943
JRS: In article <aa************ *************** ***@news.terane ws.com>,
seen in news:comp.lang. javascript, Treetop <tr*****@netfro nt.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.demo n.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demo n.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.terane ws.com>,
seen in news:comp.lang. javascript, Treetop <tr*****@netfro nt.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:'Summe r Time On'}},
Y2004:{M04:{D11 :"Easter Sunday"}} }

Yearly =
{ M04:{D01:"All Fools Day"}, M12:{D25:'Chris tmas Day'},
M10:{D21:"Trafa lgar Day"}, M06:{D18:'Water loo Day'} }

<URL:http://www.merlyn.demo n.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.demo n.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #4
Dr John Stockton <sp**@merlyn.de mon.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**********@h otpop.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.de mon.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
functionalit y. 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.demo n.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.demo n.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #6
Dr John Stockton <sp**@merlyn.de mon.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.pro totype.join.cal l(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
14876
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 CCYYMMDD. Sounds easy enough, right?? I am attempting to accomplish this by creating a GregorianCalender which will get me the week of year. Then by changing the day of week to 1 (start of week) i'm trying the get the first day of the week,...
0
1484
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 the mm/dd/yyyy format. I created a deployment package and installed the program on another server and it also returned the correct mm/dd/yyyy format. Recently I got complaints saying that the format changed to mm-dd-yyyy format. This...
3
850
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
6924
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 CultureInfo("ar-SA", false); sa.DateTimeFormat.Calendar = new System.Globalization.HijriCalendar(); // Sets the culture to Arabic (Saudi Arabia) Thread.CurrentThread.CurrentCulture = sa;
3
3119
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 example, they clock on August 13th, and in texbox1, it will say "Wedding, 2:00 PM". How do I get started?
12
3426
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 ending date. Here is the primary page that I have <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Your Title</title>
3
2724
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 assist with this. Thanks in advance. I have an access database that i have added a pop up calendar to, the Table information for the Date Reported field is Date/Time format short date, input mask is 00/00/0000.
0
3323
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 would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
4
3330
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 the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
7
2292
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 that info, but somewhere I've gone completely off the rails! Basically it is a room availability page for an intranet and should simply colour a calendar cell red if the room is booked, or green if it isn't. Rooms are typically booked by lecturers...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8855
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.