Jump to content

totally lost


george

Recommended Posts

I have a calendar and an array of events. As the calendar is being written, it checks to see if the date being written is a scheduled date or a proposed date. Scheduled dates appear in one color, proposed dates in another. This works fine. I want to enable the user to click on a scheduled date and up pops a balloon providing the name of the event scheduled. This also works fine. . . but only for event scheduled. The code for the proposed and scheduled checking are identical. I can not find why one little function works, and the other does not. Further, I don’t even know if I am using the right strategy to achieve this effect for a series of events. I can get only one scheduled event, and one proposed event, to appear color coded on the calendar. Even though there is an array (2dim), if I try and step through the array in the scheduled or the proposed functions, I get an error. The calendar works, even though I spelled calendar wrong. But I can not advance past this. I can get multiple events to appear -, but not multiple events. Also, only one balloon is working. I don’t get it. I am totally confounded. Here is my complete monster, save the balloon gif. displaying the balloon with message is not a problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript">/************************************************ Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/* Script featured on Dynamic Drive (http://www.dynamicdrive.com)* This notice must stay intact for use* Visit http://www.dynamicdrive.com/ for full source code***********************************************//* modified by George, as described. */var aAsk1 = new Array('Brandi Wine', 'recno=3', '3/10/2007 3/11/2007 3/12/2007');var aAsk2 = new Array('Cherry Wine', 'recno=1', '3/20/2007 3/21/2007 3/22/2007');var aProposed = new Array();aProposed[0] = aAsk1;aProposed[1] = aAsk2;var aTell1 = new Array('Apple Cider', 'recno=3', '4/10/2007 4/11/2007 4/12/2007');var aTell2 = new Array('Ginger Ale', 'recno=1', '4/20/2007 4/21/2007 4/22/2007');var aScheduled = new Array();aScheduled[0] = aTell1;aScheduled[1] = aTell2;var zName;function buildCal(m, y, cM, cH, cDW, cD, brdr){	var mn=['January','February','March','April','May','June','July','August','September','October','November','December'];	var dim=[31,0,31,30,31,30,31,31,30,31,30,31];	var oD = new Date(y, m-1, 1); //DD replaced line to fix date bug when current day is 31st	oD.od=oD.getDay()+1; //DD replaced line to fix date bug when current day is 31st	dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYear()%400==0))?29:28;	var t='<div class="'+cM+'"><table class="'+cM+'" id="'+cM+'" cols="7" cellpadding="0" border="'+brdr+'" cellspacing="0"  ><tr align="center">';	t+='<td colspan="7" align="center" class="'+cH+'">'+mn[m-1]+' - '+y+'</td></tr><tr align="center">';	for(s=0;s<7;s++)		t+='<td class="'+cDW+'">'+"SMTWTFS".substr(s,1)+'</td>';		t+='</tr><tr align="center">';		for(i=1;i<=42;i++){			var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : ' ';			t+=WhichOne(x,m,y);			if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';		}		return t+='</tr></table></div>';	}function WhichOne(zDay, zMonth, zYear) {	var todaydate=new Date();	var scanfortoday=(zYear==todaydate.getFullYear() && zMonth==todaydate.getMonth()+1)? todaydate.getDate() : 0;	var getThis = '';	if (getThis = inproposed(zMonth, zDay, zYear)) {		return "<td id='proposed' onclick='zBaloon("+getThis+",event);'>"+zDay+"</td>";	} else if (getThis = inscheduled(zMonth, zDay, zYear)) {		return "<td id='scheduled' onclick='zBalloon("+getThis+",event);'>"+zDay+"</td>";	} else if (zDay == scanfortoday) {		return "<td id='today'>"+zDay+"</td>";	} else if (zDay != scanfortoday) {		return "<td id='anyday'>"+zDay+"</td>";	}}function inscheduled(zMonth, zDay, zYear) {	zDate = zMonth + '/' + zDay + '/' + zYear;	zStr = aScheduled[0][2];	Scheduled = aScheduled[0][0];	if (zStr.indexOf(zDate)>=0) {		return 'Scheduled';	} else {		return false;	}}function inproposed(zMonth, zDay, zYear) {	zDate = zMonth + '/' + zDay + '/' + zYear;	zStr = aProposed[0][2];	Proposed = aProposed[0][0];	if (zStr.indexOf(zDate)>=0) {		return 'Proposed';	} else {		return false;	}}function zBalloon(gotThis,event) {zLeft=event.clientX -50;zTop=event.clientY - 120;document.getElementById('zBalloon').style.top = zTop;document.getElementById('zBalloon').style.left = zLeft;document.getElementById('zBalloon').style.display = 'block';document.getElementById('zBalloonTalk').innerHTML = gotThis;}function zBalloonClose() {document.getElementById('zBalloon').style.display = 'none';}</script><style type="text/css">.main {width:200px;border:1px solid black;}.month {background-color:black;font:bold 12px verdana;color:white;}.daysofweek {background-color:gray;font:bold 12px verdana;color:white;}#anyday {font-size: 12px;font-family:verdana;color:black;background-color: lightyellow;padding: 2px;}#today, #proposed, #scheduled, #todayproposed, #todayscheduled {font-size: 12px;font-family:verdana;padding: 2px;}#today {color:red;background-color: lightyellow;}#proposed	{font-weight: bold;color:#000000;background-color:#FFCCCC;cursor:hand;}#scheduled	{font-weight: bold;color:#000000;background-color:#FFCC00;cursor:hand;}#todayproposed {font-weight: bold;color:#FF0033;background-color:#FFCCCC;cursor:hand;}#todayscheduled {font-weight: bold;color:#FF0033;background-color:#FFCC00;cursor:hand;}#zBalloon { position:absolute;background-image:url(images/myzBalloon.gif);background-repeat:no-repeat;width:300px;height:140px;display:none;}#zBalloonTalk {position:absolute;top:23px;left:30px;color:#0033FF;font-family:Arial, Helvetica, sans-serif;font-size:12px;text-decoration:underline;cursor:hand;}#zBalloonClose {position:absolute;color:#0000FF;font:"Courier New", Courier, monospace;font-size:9px;font-variant:small-caps;text-decoration:underline;top:15px;right:60px;cursor:hand;}</style></head><body><p>*</p><p>*</p><p>*</p><p>*</p><p>*</p><p>*</p><span id="zBalloon"><span id="zBalloonTalk" >Fred</span><span id="zBalloonClose" onclick="zBalloonClose();">close <img src="images/redx.gif" /></span></span><table border="0" cellspacing="0" cellpadding="3"><tr><td width="33%"><script>document.write(buildCal(3,2007, "main", "month", "daysofweek", "days", 1)); </script></td><td width="33%"><script>document.write(buildCal(4,2007, "main", "month", "daysofweek", "days", 1));</script></td><td width="34%"><script>document.write(buildCal(5,2007, "main", "month", "daysofweek", "days", 1));</script></td></tr></table><p><hr /></p><table border="0"><tr><td bgcolor="#FFCCCC">    </td><td bgcolor="#000000" style="color:#FFFFFF">Proposed event</td></tr><tr><td bgcolor="#FFCC00">    </td><td bgcolor="#000000" style="color:#FFFFFF">Scheduled event</td></tr></table></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...