Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Sacramento, CA USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Question about Calendars! Please help!

    I have some script to create a calendar, but I've never really used javascript before, and I don't know how to edit it so I can put more functions in... I have the functions, I just don't know where to put 'em!

    Yeah, so, if anyone reads this is the next hour or so, AIM me, or email with some help, would you? I'd be much obliged.

    (I REALLY need to know how to get the function where the user can click on a day and get a pop up window with the date info... It's for a band... Help help help!! Pleeeease.)

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts

    Cool

    Give us the script to see what can we do :-)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Sacramento, CA USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ....wow, I'm feeling stupid

    Okay, this is the script I have. I have no idea what is what... geh.


    <!--
    function getmonth(themonth0, themonth1, themonth2, themonth3, themonth4, themonth5, themonth6, themonth7, themonth8, themonth9, themonth10, themonth11)
    {
    this[0] = themonth0; this[1] = themonth1; this[2] = themonth2;
    this[3] = themonth3; this[4] = themonth4; this[5] = themonth5;
    this[6] = themonth6; this[7] = themonth7; this[8] = themonth8;
    this[9] = themonth9; this[10] = themonth10; this[11] = themonth11;
    }
    function makecalendar()
    {
    var whatIsIt = "JanFebMarAprMayJunJulAugSepOctNovDec";
    var today = new Date(); var thisDay;
    var monthDays = new getmonth(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    year=today.getFullYear(); thisDay = today.getDate();
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
    monthDays[1] = 29; nDays = monthDays[today.getMonth()];
    IsitNow = today; IsitNow.setDate(1); FindOut = IsitNow.getDate();
    if (FindOut == 2) IsitNow.setDate(0); startDay = IsitNow.getDay();
    document.write("<table border=0 bgcolor=black>");
    document.write("<tr><td colspan=7 align=center><font color=white><b>");
    document.write(whatIsIt.substring(today.getMonth() * 3, (today.getMonth() + 1) * 3));
    document.write(" "); document.write(year);
    document.write("</b></font></td></tr><tr><td align=center><font color=white><b>Sun</b></font></td><td align=center><font color=white><b>Mon</b></font></td><td align=center><font color=white><b>Tue</b></font></td><td align=center><font color=white><b>Wed</b></font></td><td align=center><font color=white><b>Thu</b></font></td><td align=center><font color=white><b>Fri</b></font></td><td align=center><font color=white><b>Sat</b></font></td></tr>");
    document.write("<tr>");
    column = 0; for (i=0; i<startDay; i++) {
    document.write("<td width=35 bgcolor=black> ");
    column++;
    }
    for (i=1; i<=nDays; i++) {
    document.write("</td><td width=35 bgcolor=black><font color=white>");
    if (i == thisDay)
    document.write("<font color=\"blue>\"><b>")
    document.write(i);
    if (i == thisDay)
    document.write("</b></font>")
    column++;
    if (column == 7) {
    document.write("</td></tr><tr>");
    column = 0;
    }
    }
    document.write("</tr></table>");
    }
    makecalendar();
    // -->

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here this should do it, you need to copy the entire code. the blace u chould put ur click funktion is in bold, I have just put an alert there.

    Code:
    <script>
    <!--
    function getmonth(themonth0, themonth1, themonth2, themonth3, themonth4, themonth5, themonth6, themonth7, themonth8, themonth9, themonth10, themonth11)
    {
    this[0] = themonth0; this[1] = themonth1; this[2] = themonth2;
    this[3] = themonth3; this[4] = themonth4; this[5] = themonth5;
    this[6] = themonth6; this[7] = themonth7; this[8] = themonth8;
    this[9] = themonth9; this[10] = themonth10; this[11] = themonth11;
    }
    function makecalendar()
    {
    var whatIsIt = "JanFebMarAprMayJunJulAugSepOctNovDec";
    var today = new Date(); var thisDay;
    var monthDays = new getmonth(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    var month=whatIsIt.substring(today.getMonth() * 3, (today.getMonth() + 1) * 3)
    year=today.getFullYear(); thisDay = today.getDate();
    if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
    monthDays[1] = 29; nDays = monthDays[today.getMonth()];
    IsitNow = today; IsitNow.setDate(1); FindOut = IsitNow.getDate();
    if (FindOut == 2) IsitNow.setDate(0); startDay = IsitNow.getDay();
    document.write("<table border=0 bgcolor=black>");
    document.write("<tr><td colspan=7 align=center><font color=white><b>");
    document.write(month);
    document.write(" "); document.write(year);
    document.write("</b></font></td></tr><tr><td align=center><font color=white><b>Sun</b></font></td><td align=center><font color=white><b>Mon</b></font></td><td align=center><font color=white><b>Tue</b></font></td><td align=center><font color=white><b>Wed</b></font></td><td align=center><font color=white><b>Thu</b></font></td><td align=center><font color=white><b>Fri</b></font></td><td align=center><font color=white><b>Sat</b></font></td></tr>");
    document.write("<tr>");
    column = 0; for (i=0; i<startDay; i++) {
    document.write("<td width=35 bgcolor=black> ");
    column++;
    }
    for (i=1; i<=nDays; i++) {
    document.write("</td><td width=35 bgcolor=black   onClick='alert(\""+i+"-"+month+"\");'><font color=white>");
    if (i == thisDay)
    document.write("<font color=blue><b>")
    document.write(i);
    if (i == thisDay)
    document.write("</b></font>")
    column++;
    if (column == 7) {
    document.write("</td></tr><tr>"); 
    column = 0;
    }
    }
    document.write("</tr></table>");
    }
    makecalendar();
    </script>

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    If i understand well, u wanna click on a date and, on this event, something should happen, ie. a pop up or so

    Wel, if u can see, that table and those date are generated by a document.write method, so u can insert there whatever events and call other functions u want.

    Unfortunately, the numbers are generated as increments, followinf a "for cicle", so the problem will be a little bit difficult, because you have to insert an "if satement", something like:

    for (i=1; i<=nDays; i++) {

    //the insertion is below

    if (i== 10)
    document.write ("<a href=\"#\" onclick=\"javascript:alert(\'bla\')\"> ");
    document.write(i);
    document.write ("</a>");
    //end insertion

    The result is that u obtain now a link on the day 10. Onclik appears a n alert, but u can obtain whichever action u need.

    You got the ideea? I don't know how much javascript you know, so I don't know if i shoul expand or no those expalantions.

    Beware, when insert HTML into document.write("") u have to remember that the genuine " have to be preceeded by /, like this /", so Javascript will know that there have to write it as a string, not as a reserved operator
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    sorry, not a backslash. The correct form is \".
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It looks it is not a good position for that insertion, but the principle look fair to me. Somewere is a syntax problem, anyway...:-)
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    Regular Coder
    Join Date
    Dec 2002
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Question about Calendars! Please help!

    Originally posted by Astillac
    I have some script to create a calendar, but I've never really used javascript before, and I don't know how to edit it so I can put more functions in... I have the functions, I just don't know where to put 'em!
    I don't know if it helps you, but I've created a popup calendar with less than 4K of JavaScript. If it looks like it might suit your purpose, let me know I may even tailor it for you.

    :ca_redwards.

  • #9
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's my calendar script:
    http://www.skyzyx.com/scripts/calendar.htm

    Hope this helps!
    Last edited by Skyzyx; 09-19-2003 at 02:19 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •