PDA

View Full Version : Onclick multiple actions?



harlem
01-22-2010, 09:51 AM
http://biologi.atspace.com/index2.htm

The "START" button on the page takes you back to the current month of the year if changing to, for example, March. But it doesn't take you back to the presentation text you will see within the tooltip to the right before you have clicked a yellow/green date within the calendar.

I want to, when you press "START", to make two actions at the same time:
1) Take me back to the current month (like now)
2) Take me back to the first text you see when you enter the homepage.

vwphillips
01-22-2010, 11:17 AM
var thisDate = 1; // Tracks current date being written in calendar
var wordMonth = new Array("JAN","FEB","MAR","APR","MAJ","JUN","JUL","AUG","SEP","OKT","NOV","DEC");
var today = new Date(); // Date object to store the current date
var todaysDay = today.getDay() + 0; // Stores the current day number 1-7
var todaysDate = today.getDate(); // Stores the current numeric date within the month
var todaysMonth = today.getUTCMonth() + 1; // Stores the current month 1-12
var todaysYear = today.getFullYear(); // Stores the current year
var monthNum = todaysMonth; // Tracks the current month being displayed
var yearNum = todaysYear; // Tracks the current year being displayed
var firstDate = new Date(String(monthNum)+"/1/"+String(yearNum)); // Object Storing the first day of the current month
var firstDay = firstDate.getUTCDay(); // Tracks the day number 1-7 of the first day of the current month
var lastDate = new Date(String(monthNum+0)+"/0/"+String(yearNum)); // Tracks the last date of the current month
var numbDays = 0;
var calendarString = "";
var eastermonth = 0;
var easterday = 0;
var ToolTipHTML=false;

function Restore() {
document.getElementById('tooltip').innerHTML=ToolTipHTML||'';
}

function changedate(buttonpressed) {
if (!ToolTipHTML){
ToolTipHTML=document.getElementById('tooltip').innerHTML;
}
if (buttonpressed == "prevyr") yearNum--;
else if (buttonpressed == "nextyr") yearNum++;
else if (buttonpressed == "prevmo") monthNum--;
else if (buttonpressed == "nextmo") monthNum++;
else if (buttonpressed == "return") {
monthNum = todaysMonth;
yearNum = todaysYear;
}

if (monthNum == 0) {
monthNum = 12;
yearNum--;
}
else if (monthNum == 13) {
monthNum = 1;
yearNum++
}

lastDate = new Date(String(monthNum+1)+"/0/"+String(yearNum));
numbDays = lastDate.getDate();
firstDate = new Date(String(monthNum)+"/0/"+String(yearNum));
firstDay = firstDate.getDay() + 0;
createCalendar();
return;
}


function easter(year) {
// feed in the year it returns the month and day of Easter using two GLOBAL variables: eastermonth and easterday
var a = year % 19;
var b = Math.floor(year/100);
var c = year % 100;
var d = Math.floor(b/4);
var e = b % 4;
var f = Math.floor((b+8) / 25);
var g = Math.floor((b-f+1) / 3);
var h = (19*a + b - d - g + 15) % 30;
var i = Math.floor(c/4);
var j = c % 4;
var k = (32 + 2*e + 2*i - h - j) % 7;
var m = Math.floor((a + 11*h + 22*k) / 451);
var month = Math.floor((h + k - 7*m + 114) / 31);
var day = ((h + k - 1*m +114) % 31) + 1;
eastermonth = month;
easterday = day;
}


function createCalendar() {
calendarString = '';
var daycounter = 0;
calendarString += '<table class="mytable" width="200" cellpadding="0" cellspacing="0">';
calendarString += '<tr>';
calendarString += '<td bgcolor=\"#FFFFC8\" align=\"center\" valign=\"center\" width=\"50\" height=\"22\" colspan=\"2\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:1px;border-style:solid;font-family:arial;font-size:11px;margin:2px;"><a style="cursor:pointer;" onClick=\"changedate(\'prevmo\')\" >FÖRRA<\/a><\/td>';
calendarString += '<td bgcolor=\"#AAFFAA\" align=\"center\" valign=\"center\" width=\"110\" height=\"22\" colspan=\"3\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:1px;border-style:solid;font-family:arial;font-size:11px;margin:2px;"><b>' + wordMonth[monthNum-1] + '&nbsp;' + yearNum + '<\/b><\/td>';
calendarString += '<td bgcolor=\"#FFFFc8\" align=\"center\" valign=\"center\" width=\"50\" height=\"22\" colspan=\"2\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:1px;border-style:solid;font-family:arial;font-size:11px;margin:2px;"><a style="cursor:pointer;" onClick=\"changedate(\'nextmo\')\">NÄSTA<\/td>';
calendarString += '<\/tr>';
calendarString += '<tr>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>M</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>T</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>O</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>T</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>F</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:0px;border-style:solid;font-size:12px;font-family:arial;"><strong>L</strong><\/td>';
calendarString += '<td bgcolor=\"#90cd90\" align=\"center\" valign=\"center\" width=\"20\" height=\"12\" style="border-color:#000000;border-top-width:1px;border-bottom-width:1px;border-left-width:0px;border-right-width:1px;border-style:solid;font-size:12px;font-family:arial;"><strong>S</strong><\/td>';

calendarString += '<\/tr>';

thisDate == 0;

for (var i = 1; i <= 6; i++) {
calendarString += '<tr>';
for (var x = 1; x <= 7; x++) {
daycounter = (thisDate - firstDay)+0;
thisDate++;
if ((daycounter > numbDays) || (daycounter < 1)) {
calendarString += '<td align=\"center\" bgcolor=\"#cccddd\" height=\"22\" width=\"30\">&nbsp;<\/td>';
} else {
if (checkevents(daycounter,monthNum,yearNum,i,x) || ( ((todaysDay == x)||(todaysDay == (x-7))) && (todaysDate == daycounter) && (todaysMonth == monthNum))){
if ( ((todaysDay == x)||(todaysDay == (x-7))) && (todaysDate == daycounter) && (todaysMonth == monthNum)) {
//add this if statement to check and see if it is an event today
if (checkevents(daycounter,monthNum,yearNum,i,x))
{
// if true make the bgcolor what ever color you like other than green or yellow
calendarString += '<td align=\"center\" bgcolor=\"#FFBBBB\" height=\"22\" width=\"30\" style=font-weight:bold;font-size:12px;font-family:arial;cursor:pointer; onclick=\"showevents(this,' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ');\" >' + daycounter + '<\/td>';
}
else
{
calendarString += '<td align=\"center\" bgcolor=\"#AAFFAA\" height=\"22\" width=\"30\" style=font-size:12px;font-family:arial;cursor:pointer; onclick=\"showevents(this,' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ');\" >' + daycounter + '<\/td>';
} }
else calendarString += '<td align=\"center\" bgcolor=\"#FFFFC8\" height=\"22\" width=\"30\" style=font-weight:bold;font-size:12px;font-family:arial;cursor:pointer; onclick=\"showevents(this,' + daycounter + ',' + monthNum + ',' + yearNum + ',' + i + ',' + x + ');\" >' + daycounter + '<\/td>';
} else {
calendarString += '<td align=\"center\" bgcolor=\"#DDFFFF\" height=\"22\" width=\"30\" style=font-size:12px;font-family:arial;>' + daycounter + '<\/td>';
}
}
}
calendarString += '<\/tr>';
}

calendarString += '<td bgcolor=\"#FFFFC8\" align=\"center\" valign=\"center\" height=\"22\" colspan=\"2\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:0px;border-style:solid;font-family:arial;font-size:11px;"><a style="cursor:pointer;" onClick=\"changedate(\'return\');Restore()\" >START<\/a><\/td>';
calendarString += '<td bgcolor=\"#FFFFC8\" align=\"center\" valign=\"center\" height=\"22\" colspan=\"3\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:0px;border-style:solid;font-family:arial;font-size:11px;"><a href=\"#\" onClick=\"changedate(\'return\')\">&nbsp;&nbsp;<\/a><\/td>';
calendarString += '<td bgcolor=\"#FFFFC8\" align=\"center\" valign=\"center\" height=\"22\" colspan=\"2\" style="border-color:#000000;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;border-right-width:1px;border-style:solid;font-family:arial;font-size:11px;"><a style="cursor:pointer;" href=\"http://www.contact.cybertools.se/guestbook.asp?id=32178">G-BOK<\/a><\/td>';

var object=document.getElementById('calendar');
object.innerHTML= calendarString;
thisDate = 1;
}

harlem
01-22-2010, 11:49 AM
Thank you, exactly what I needed! *happy*