Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Graying out" text (strings)

    Looking for help. I am creating a JS based web calendar for a non profit organization. The way it now stands, clicking on a date in the calendar displays that day's events for the organization. At present, there is no way to distinguish between dates with events and dates with none. My idea is to create a function that checks the contents of the array that holds the events, and if the string is empty change the date link's color to gray. I am trying to use the fontcolor method of the string object. I am not having any luck.

    Here's a snippet of the code. The full code is available at <A target="_blank" HREF=http://www.abingtondemocrats.org/may2001.shtml>http://www.abingtondemocrats.org/may2001.shtml</A>.

    This is the array holding the event info:
    <pre><script TYPE="text/javascript" LANGUAGE="JavaScript">

    dayInfo = new Array
    dayInfo[1] = ""
    dayInfo[2] = ""
    dayInfo[3] = ""
    dayInfo[4] = ""
    dayInfo[5] = ""
    dayInfo[6] = ""
    dayInfo[7] = "ARDC monthly meeting - St.
    Mark's Episcopal Church. Democrat of the Year will be
    announced."
    dayInfo[8] = ""
    dayInfo[9] = ""
    dayInfo[10] = ""
    dayInfo[11] = ""
    dayInfo[12] = ""
    dayInfo[13] = ""
    dayInfo[14] = ""
    dayInfo[15] = "Primary Election Day -Polls
    open from 7:00 AM to 8:00 PM"
    dayInfo[16] = ""
    dayInfo[17] = ""
    dayInfo[18] = ""
    dayInfo[19] = ""
    dayInfo[20] = ""
    dayInfo[21] = ""
    dayInfo[22] = ""
    dayInfo[23] = ""
    dayInfo[24] = ""
    dayInfo[25] = ""
    dayInfo[26] = ""
    dayInfo[27] = ""
    dayInfo[28] = ""
    dayInfo[29] = ""
    dayInfo[30] = ""
    dayInfo[31] = "ARDC Annual Banquet"
    </pre>


    Here is the function which displays the event in the calendar:
    <pre>function showInfo(thisDay) {
    document.calendar.dateInfo.value = dayInfo[thisDay]
    }
    </pre>

    Here is the link code that actually displays the event in a textarea field of a form. The links are in a table formatted calendar.
    <pre>1
    </pre>


    Here is the non working attempt at graying out the empty dates
    <pre>function noEvent(dateString,thisDay) {
    document.write(dateString)
    if (dayInfo[thisDay] == "")
    dateString.fontcolor = "Gray"
    }
    </pre>

    and
    <pre><A HREF="java script:showInfo(1)">
    <script type="text/javascript" language="JavaScript">
    noEvent(1,1)
    </script>
    </A>
    </pre>

    dateString is an array of strings for each day of the month.

    noEvent displays the date string, but the color is the default link color. Any ideas?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re:

    Try something like this (pseudocode, since I don't know JavaScript very well):

    function noEvent(dateString,thisDay) {
    if (dayInfo[thisDay] == "") {
    document.write("<FONT Color = ""Gray"">"
    document.write(dateString)
    document.write("</FONT>") }
    else
    document.write(dateString)
    }

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re:

    Bingo! While I haven't tried it, I know it will work by looking at it. Did you say you didn't know JavaScript very well?

    Thanks........

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re:

    Yeah, I know only enough to be dangerous. The rest is a guess based on VBA/VBScript.

Posting Permissions

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