Javascript "annual program"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jacotheron
    New Member
    • Jan 2008
    • 44

    Javascript "annual program"

    I am new to javascript. One of my clients asked me to make a dynamic anual program that can remove the events that already have happened. I have tried doing it with a javascript array, but it is a very big multi dimensional array and I have lost track of where am I. (The contents is Afrikaans as the organisation want it in Afrikaans)

    Can someone please help me?
    email me @ [EMAIL removed]
    Last edited by acoder; Jan 13 '08, 01:12 PM. Reason: removed email
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Post the code that you've programmed so far.

    Note that I've removed your email. This is for your own security as pointed out in the posting guidelines.

    Comment

    • Jacotheron
      New Member
      • Jan 2008
      • 44

      #3
      Thank you for replying to my problem. As I said earlier, there are Afrikaans of the info that should be printed on the page. This is the code that I have programmed so far:

      [code=javascript]var currentDate = new Date();
      var day = currentDate.get Date();
      var month = currentDate.get Month()+1;
      if (month >= 1 && month <=9) month = "0" + month;
      var year = currentDate.get FullYear();
      var fullDate = (day + "-" + month + "-" + year);
      document.write( fullDate);

      var jp = new Array();

      for (i=0; i <128; i++)
      jp[i] = new Array(2)
      // [1] = DatumEind; [2] = Datum; Gebuertenis; Verantwoordelik heid; ABC

      jp[0][1] = "04-01-2008";
      jp[0][2] = "4 Januarie; Sluitingsdatum - Voriesaamtrek";

      jp[1][1] = "05-01-2008"
      jp[1][2] = "4 - 5 Januarie; P/D Seejol Keurkamp"

      jp[2][1] = "09-01-2008"
      jp[2][2] = "9 Januarie; Skole Open"

      jp[3][1] = "12-01-2008"
      jp[3][2] = "11 - 12 Januarie; Voriesaamtrek"

      jp[4][1] = "14-01-2008"
      jp[4][2] = "14 Januarie; Vissershoek Inligtingsaand; Abri, Hanno & Liesl"

      jp[5][1] = "15-01-2008"
      jp[5][2] = "15 Januarie; Theresapark Inligtingsaand Gr 1, 2 & 3; Abri, Veronica & Liesl"

      jp[6][1] = "16-01-2008"
      jp[6][2] = "16 Januarie; Theresapark Inligtingsaand Gr 4 & 5"

      jp[7][1] = "21-01-2008"
      jp[7][2] = "21 Januarie; Waterspeletjies Arbeidsvreugde; Abri, Liesl, Stefanie & Albert"

      jp[8][1] = "21-01-2008"
      jp[8][2] = "21 Januarie; Kommandobestuur svergadering; Wietske & Amanda"

      jp[9][1] = "25-01-2008"
      jp[9][2] = "25 Januarie; Waterspeletjies Vissershoek; Abri, Liesl & Hanno"

      jp[10][1] = "28-01-2008"
      jp[10][2] = "28 Januarie; Spanbyeenkoms (1)"

      jp[11][1] = "31-01-2008"
      jp[11][2] = "31 Januarie; Tempin Bowling Kuieraand Offisiere"

      jp[12][1] = "31-01-2008"
      jp[12][2] = "31 Januarie; Sperdatum : Berigte vir Hou Koers Nr 1"


      jp[13][1] = "02-02-2008"
      jp[13][2] = "1 - 2 Februarie; Kamp Sifdraad & Offisiere Inlywing; Corlia, Hanno & Stefanie"

      jp[14][1] = "04-02-2008"
      jp[14][2] = "4 Februarie; Spanbyeenkoms & Koek & Koeldrank vir Kinders (2); Veronica & Wietske"

      jp[15][1] = "06-02-2008"
      jp[15][2] = "6 Februarie; Koek & Tee vir Onderwysers - Theresapark; Wietske, Amanda & Abri"

      jp[16][1] = "08-02-2008"
      jp[16][2] = "8 Februarie; Jaarverslag in; Veronica & Fritz"

      jp[17][1] = "09-02-2007"
      jp[17][2] = "9 Februarie; Transmagalies – Informele Opleidingsdag vir offisiere - Noordpos"

      jp[18][1] = "11-02-2008"
      jp[18][2] = "11 Februarie; Spanbyeenkoms (3)"

      jp[19][1] = "16-02-2008"
      jp[19][2] = "15 - 16 Februarie; Kentekendag – Linden Voortrekkerkomm ando - JHB"

      jp[20][1] = "16-02-2008"
      jp[20][2] = "16 Februarie; Graad 12 inskrywings - sluitingsdatum by kommando's"[/code]

      [code=javascript]jp[21][1] = "18-02-2008"
      jp[21][2] = "18 Februarie; Spanbyeenkoms (4)"

      jp[22][1] = "22-02-2008"
      jp[22][2] = "22 Februarie; Ledelys 2008 - Eerste betaling met ledelys by gebiedskantoor; Liesl & Fritz"

      jp[23][1] = "23-02-2008"
      jp[23][2] = "23 Februarie; Opleidingsdag – P/D & Verkenner Offisiere"

      jp[24][1] = "25-02-2008"
      jp[24][2] = "25 Februarie; Spanbyeenkoms (5)"

      jp[25][1] = "25-02-2008"
      jp[25][2] = "25 Februarie; Sluitingsdatum van Graad 12 - Gebiedskantoor - Volledige proses"

      jp[26][1] = "29-02-2008"
      jp[26][2] = "29 Februarie; Spanbyeenkoms - Vissershoek (iv)"


      jp[27][1] = "01-03-2008"
      jp[27][2] = "29 Februarie - 1 Maart; Kentekendag - Kruinsig Voortrekkerkomm ando - Kempton Park"

      jp[28][1] = "01-03-2008"
      jp[28][2] = "1 Maart; Graad 12 Afronding - Oord Monument"

      jp[29][1] = "03-03-2008"
      jp[29][2] = "3 Maart; Spanbyeenkoms (6)"

      jp[30][1] = "03-03-2008"
      jp[30][2] = "3 Maart; Kommandobestuur vergadering; Veronica & Albert"

      jp[31][1] = "10-03-2008"
      jp[31][2] = "10 Maart; Spanbyeenkoms (7)"

      jp[32][1] = "15-03-2007"
      jp[32][2] = "15 Maart; Kentekendag - Sytze Wierda Voortrekkerkomm ando - Wierdapark"

      jp[33][1] = "17-03-2007"
      jp[33][2] = "17 Maart; Kommandobyeenko ms (A); Veronica & Wietske; ABC punte"

      jp[34][1] = "20-03-2008"
      jp[34][2] = "20 Maart; Skole Sluit"

      jp[35][1] = "30-03-2008"
      jp[35][2] = "21 - 30 Maart; Verkenner Lunsklip Gebiedskamp"

      jp[36][1] = "30-03-2008"
      jp[36][2] = "23 - 30 Maart; Verkenner Roodeplaat Gebiedskamp"

      jp[37][1] = "31-03-2008"
      jp[37][2] = "25- 31 Maart; Verkenner Thaba Veldwerk Gebiedskamp"

      jp[38][1] = "30-03-2008"
      jp[38][2] = "26 - 30 Maart; P/D Hoëveld Gebiedskamp"

      jp[39][1] = "02-04-2008"
      jp[39][2] = "28 Maart - 2 April; P/D Noordelike Gebieskamp"

      jp[40][1] = "28-03-2008"
      jp[40][2] = "28 Maart; Ledelys 2008 - opgedateer - Tweede oorbetaling by gebied"

      jp[41][1] = "06-04-2008"
      jp[41][2] = "1 - 6 April; P/D Waterwerk Gebiedskamp"

      jp[42][1] = "06-04-2008"
      jp[42][2] = "4 - 6 April; Volwasse Seilkursus - De Bank"

      jp[43][1] = "12-04-2008"
      jp[43][2] = "5 - 12 April; Verkenner - Rus Keeti Veldwerk Gebiedskamp"

      jp[44][1] = "13-04-2008"
      jp[44][2] = "9 - 13 April; P/D Jakaranda Gebiedskamp"

      jp[45][1] = "14-04-2008"
      jp[45][2] = "14 April; Skole Heropen"

      jp[46][1] = "20-04-2008"
      jp[46][2] = "18 - 20 April; Graad 12 Afrondingsnawee k"

      jp[47][1] = "20-04-2008"
      jp[47][2] = "20 April; Kerkparade en inlywing; Riekie & Stefanie; ABC punte"

      jp[48][1] = "21-04-2008"
      jp[48][2] = "21 April; Spanbyeenkoms (8)"

      jp[49][1] = "25-04-2007"
      jp[49][2] = "25 April; Ledelys 2008 - finaal - 3de betaling by gebied; Fritz & Liesl"

      jp[50][1] = "30-04-2008"
      jp[50][2] = "30 April; Sperdatum vir Hou Koers berigte"[/code]

      [code=javascript]jp[51][1] = "04-05-2008"
      jp[51][2] = "1 - 4 Mei; Kommandokamp"

      jp[52][1] = "03-05-2008"
      jp[52][2] = "3 Mei; OBS Dinee"

      jp[53][1] = "05-05-2008"
      jp[53][2] = "5 Mei; Spanbyeenkoms (9)"

      jp[54][1] = "05-05-2008"
      jp[54][2] = "5 Mei; Kommandobestuur vergadering; Abri & Riekie"

      jp[55][1] = "09-05-2008"
      jp[55][2] = "9 Mei; Verkenners - Transvaalse Jeugberaad"

      jp[56][1] = "10-05-2008"
      jp[56][2] = "9 - 10 Mei; Gebiedsjeugraad verkiesing"

      jp[57][1] = "10-05-2008"
      jp[57][2] = "10 Mei; Staatmakers - OBS Dinee"

      jp[58][1] = "11-05-2008"
      jp[58][2] = "11 Mei; Oord Kerkparade - Voor-die-Berg; ABC punte"

      jp[59][1] = "12-05-2008"
      jp[59][2] = "12 Mei; Spanbyeenkoms (10)"

      jp[60][1] = "16-05-2008"
      jp[60][2] = "16 Mei; Halfjaarverslag Indien"

      jp[61][1] = "17-05-2008"
      jp[61][2] = "16 - 17 Mei; P/D Kentekendag Rooihuiskraal Voortrekkerkomm ando"

      jp[62][1] = "17-05-2008"
      jp[62][2] = "17 Mei; P/D Kentekendag Genl Hertzog Voortrekkerkomm ando"

      jp[63][1] = "19-05-2008"
      jp[63][2] = "19 Mei; Spanbyeenkoms (11)"

      jp[64][1] = "25-05-2008"
      jp[64][2] = "23 - 25 Mei; Volwasse Opleidingskamp Spesialiserings kamp - Hartebeesfontei n"

      jp[65][1] = "26-05-2008"
      jp[65][2] = "26 mei; Spanbyeenkoms (12)"

      jp[66][1] = "30-05-2008"
      jp[66][2] = "30 Mei; Laaste dag vir lede registrasie"

      jp[67][1] = "02-06-2008"
      jp[67][2] = "2 Junie; Spanbyeenkoms (13)"

      jp[68][1] = "02-06-2008"
      jp[68][2] = "2 Junie; Kommandobestuur vergadering; Fritz & Thea"

      jp[69][1] = "07-06-2008"
      jp[69][2] = "7 Junie; Verkenneroffisi ere Opleidingsdag"

      jp[70][1] = "09-06-2008"
      jp[70][2] = "9 Junie; Spanbyeenkoms (14)"

      jp[71][1] = "10-06-2008"
      jp[71][2] = "10 Junie; Oordbestuursver gadering; Stefanie, Abri, Amanda, Liesl & Hanno"

      jp[72][1] = "13-06-2008"
      jp[72][2] = "13 Junie; Sop, Broodjie & Speletjieaand"

      jp[73][1] = "20-06-2008"
      jp[73][2] = "20 Junie; Skole Sluit"

      jp[74][1] = "29-06-2008"
      jp[74][2] = "21 - 29 Junie; P/D Swartvlei Gebiedskamp"

      jp[75][1] = "30-06-2008"
      jp[75][2] = "25 - 30 Junie; Innibos Kunstefees"

      jp[76][1] = "30-06-2008"
      jp[76][2] = "27 - 30 Junie; Verkenner Seejol Gebiedskamp"

      jp[77][1] = "14-07-2008"
      jp[77][2] = "14 Julie; Skole Heropen"

      jp[78][1] = "18-07-2008"
      jp[78][2] = "18 Julie; Oord Offisiere Kuieraand (Oord Pta Moot)"

      jp[79][1] = "21-07-2008"
      jp[79][2] = "21 Julie; Spanbyeenkoms (15)"

      jp[80][1] = "26-07-2008"
      jp[80][2] = "26 Julie; Oord Voorslagafrondi ng - Voor-die-Berg"[/code]

      [code=javascript]jp[81][1] = "28-07-2008"
      jp[81][2] = "28 Julie; Spanbyeenkoms (16)"

      jp[82][1] = "31-07-2008"
      jp[82][2] = "31 Julie; Sperdatum - Hou Koers berigte"

      jp[83][1] = "01-08-2008"
      jp[83][2] = "1 Augustus; Sluitingsdatum: Voorslagkamp"

      jp[84][1] = "02-08-2008"
      jp[84][2] = "1 - 2 Augustus; Kentekendag: Garsvallei Voortrekkerkomm ando"

      jp[85][1] = "04-08-2008"
      jp[85][2] = "4 Augustus; Spanbyeenkoms (17)"

      jp[86][1] = "04-08-2008"
      jp[86][2] = "4 Augustus; Kommandobestuur vergadering; Liesl & Stefanie"

      jp[87][1] = "08-08-2008"
      jp[87][2] = "8 Augustus; Oord Nagmars (Arbeidsvreugde/Die Kruin Kommando)"

      jp[88][1] = "09-08-2008"
      jp[88][2] = "9 Augustus; Verkenner Nagmars"

      jp[89][1] = "11-08-2008"
      jp[89][2] = "11 Augustus; Spanbyeenkoms (18)"

      jp[90][1] = "17-08-2008"
      jp[90][2] = "15 - 17 Augustus; Gr 8-11 Vorie Vasbyt Avontuurkamp"

      jp[91][1] = "17-08-2008"
      jp[91][2] = "15 - 17 Augustus; Kentekennaweek: Wapadrand"

      jp[92][1] = "18-08-2008"
      jp[92][2] = "18 Augustus; Spanbyeenkoms (19)"

      jp[93][1] = "23-08-2008"
      jp[93][2] = "23 Augustus; Transvaal Gr 12 Oorhandigingsfu nksie"

      jp[94][1] = "25-08-2008"
      jp[94][2] = "25 Augustus; Spanbyeenkoms (20)"

      jp[95][1] = "01-09-2008"
      jp[95][2] = "1 September; Spanbyeenkoms (21)"

      jp[96][1] = "05-09-2008"
      jp[96][2] = "5 September; Geskiedenismars & Oorslaap; Hanno, Veronica & Wietske"

      jp[97][1] = "08-09-2008"
      jp[97][2] = "8 September; Spanbyeenkoms (22)"

      jp[98][1] = "14-09-2008"
      jp[98][2] = "12 - 14 September; P/D Voorslagkamp"

      jp[99][1] = "13-09-2008"
      jp[99][2] = "13 September; Kentekendag: Rietvallei Fietskaskenades "

      jp[100][1] = "15-09-2008"
      jp[100][2] = "15 September; Spanbyeenkoms (23)"

      jp[101][1] = "21-09-2008"
      jp[101][2] = "19 - 21 September; Staatmakers: Bosveldnaweek - Ellisras"

      jp[102][1] = "19-09-2008"
      jp[102][2] = "19 September; Theresapark Laerskook Kermis"

      jp[103][1] = "22-09-2008"
      jp[103][2] = "22 September; Spanbyeenkoms (24)"

      jp[104][1] = "24-09-2008"
      jp[104][2] = "23 - 24 September; Verkenner Koersvas Kanaalroei & Hartbeespoort Nagmars"

      jp[105][1] = "26-09-2008"
      jp[105][2] = "26 September; Skole Sluit"[/code]

      [code=javascript]jp[106][1] = "30-09-2008"
      jp[106][2] = "26 - 30 September; P/D Venterskroon Kamp"

      jp[107][1] = "29-09-2008"
      jp[107][2] = "27 - 29 September; Verkenner Oewerkamp"

      jp[108][1] = "02-10-2008"
      jp[108][2] = "28 September - 2 Oktober; P/D Oostelike Gebiedskamp - Ermelo"

      jp[109][1] = "04-10-2008"
      jp[109][2] = "28 September - 4 Oktober; Verkenner Wilgedraai Waterwerkkamp"

      jp[110][1] = "30-09-2008"
      jp[110][2] = "30 September; Voortrekkerverj aarsdag"

      jp[111][1] = "06-10-2008"
      jp[111][2] = "6 Oktober; Skole open"

      jp[112][1] = "06-10-2008"
      jp[112][2] = "6 Oktober; Spanbyeenkoms (25)"

      jp[113][1] = "06-10-2008"
      jp[113][2] = "6 Oktober; Kommandobestuur vergadering; Hanno, Simon & Dirk"

      jp[114][1] = "10-10-2008"
      jp[114][2] = "10 Oktober; Jaarprogramme 2009 indien"

      jp[115][1] = "13-10-2008"
      jp[115][2] = "13 Oktober; Spanbyeenkoms (26)"

      jp[116][1] = "15-10-2008"
      jp[116][2] = "15 Oktober; Oord Transmagaies - Voorslagoorhand iging"

      jp[117][1] = "15-10-2008"
      jp[117][2] = "15 Oktober; Bemarkingsdag - dra van Voortrekkerdrag "

      jp[118][1] = "18-10-2008"
      jp[118][2] = "17 - 18 Oktober; Vlotvaart - Roodeplaat"

      jp[119][1] = "18-10-2008"
      jp[119][2] = "18 Oktober; OBS Blikkieskosdag"

      jp[120][1] = "20-10-2008"
      jp[120][2] = "20 Oktober; Spanafsluiting"

      jp[121][1] = "27-10-2008"
      jp[121][2] = "27 Oktober; Kommandoafsluit ing; Amanda & Stefanie; ABC punte"

      jp[122][1] = "31-10-2008"
      jp[122][2] = "31 Oktober; Sluitingsdatum Graad 11 Projek inhandig by Gebiedskantoor"

      jp[123][1] = "31-10-2008"
      jp[123][2] = "31 Oktober; Prysuitdeling; Hanno"

      jp[124][1] = "30-11-2008"
      jp[124][2] = "28 - 30 November; Verkenners: Roodeplaat Keurroei"

      jp[125][1] = "07-12-2008"
      jp[125][2] = "5 - 7 Desember; Bosberaad; Abri & Amanda"

      jp[126][1] = "05-12-2008"
      jp[126][2] = "5 Desember; Skole sluit"

      jp[127][1] = "16-12-2008"
      jp[127][2] = "16 Desember; Geloftedagdiens by Voortrekkermonu ment"

      for (var i=0; i<128; i++) {
      if (jp[i][1] > fullDate ) {
      document.print (<p>jp[i][2]<br />);
      }
      if (jp[i][1] == fullDate ) {
      document.print (<p><b>jp[i][2]</b><br />);
      }
      }[/code]

      The quotes is to identify the start and end of the code.
      Last edited by acoder; Jan 15 '08, 08:34 AM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You could use objects using object-oriented programming, e.g. see this link.

        PS. you didn't need to show the whole code - a few lines of the array would've been enough.

        Note: you're using document.print( ), which should be document.write( ).

        Comment

        • Jacotheron
          New Member
          • Jan 2008
          • 44

          #5
          Originally posted by acoder
          You could use objects using object-oriented programming, e.g. see this link.

          PS. you didn't need to show the whole code - a few lines of the array would've been enough.

          Note: you're using document.print( ), which should be document.write( ).
          I have used a program called "1st Javascript Editor" to fix a problem in the file and it seems to work, but it disply everything in one large paragraph. I need it to give every value that needs to be included a new line and the events that is happening on the same date as the date is today to be printed in Bold.

          I looked at the site you recommended, but could not quite understand how it will hepl me with this problem.

          Anyway thanx for the help so far.

          Comment

          • Jacotheron
            New Member
            • Jan 2008
            • 44

            #6
            I have worked on this program for a few hours now and finaly got something right. The script executes well and display everything like it should, but the current date (var fulldate) is the problem.

            the evens that is still to come in about less than X months is not listed(X is for any month like today is the 15 January but every thing before the 15th of any of the folowing months is hidden by the script).

            To solve this problem I need to know how to access the some of the string in the array's value (for example
            Code:
            jp[127][1] = "16-12-2008"
            is the part of the array and I need to access the month, characters nr 4 & 5 to get the month. If the month is smaller or equal to the month of the array, it should compare the dates and after that give the result of the array.)

            Thank you for all the help so far.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by Jacotheron
              I looked at the site you recommended, but could not quite understand how it will hepl me with this problem.
              You said earlier that you found it difficult to keep track of where you were, so I gave you a link to an alternative implementation which might make it easier to keep track of things because you can set properties for the objects.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Originally posted by Jacotheron
                To solve this problem I need to know how to access the some of the string in the array's value (for example
                Code:
                jp[127][1] = "16-12-2008"
                is the part of the array and I need to access the month, characters nr 4 & 5 to get the month. If the month is smaller or equal to the month of the array, it should compare the dates and after that give the result of the array.)
                Use the split() method to split the string and then get the second string in the resulting array.

                Comment

                • Jacotheron
                  New Member
                  • Jan 2008
                  • 44

                  #9
                  Originally posted by acoder
                  Use the split() method to split the string and then get the second string in the resulting array.
                  OK I will try this.

                  Thanx for the help

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Let us know how you manage.

                    Comment

                    • Jacotheron
                      New Member
                      • Jan 2008
                      • 44

                      #11
                      Originally posted by acoder
                      Let us know how you manage.
                      Well I have changed a few things in the code and now it is working like it should.

                      Thank you for the help you have given me.

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Originally posted by Jacotheron
                        Well I have changed a few things in the code and now it is working like it should.

                        Thank you for the help you have given me.
                        Well done! Glad you managed to get it working.

                        Comment

                        Working...