PDA

View Full Version : Hyperlinks on dates (basic html calendar)



centipede
08-02-2017, 09:36 PM
1) Script Title: Basic Calendar

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex7/basiccalendar.htm

3) Describe problem: I need to add my own hyperlinks to specific dates on this calendar, I'm not too experienced in any of this and I think it would be better to just ask instead of spending a ton of time figuring it on my own. Google wasn't of much help but a similar question was asked years ago, it just did it differently. I can't figure out how to make it work the way I want.

jscheuer1
08-02-2017, 10:17 PM
How did it do it? And how do you want it done?

centipede
08-03-2017, 03:30 PM
Hey! You're the same guy that replied to the last question about this. The one you did sent it to a specific page named after the date like Dec 10th 2016 would sent to the page 12102016.htm or something like that. What I need is to be able to link specific dates to actual web links like to google.com or any other website for example. Thank you for replying

centipede
08-03-2017, 03:32 PM
here was the thread I found about it but it didn't accomplish what I wanted it to http://www.dynamicdrive.com/forums/showthread.php?6383-Basic-calendar-with-hyperlinks

jscheuer1
08-03-2017, 06:01 PM
OK, working from that thread, make your special days array look like so:


var specialDays=new Array()
// set special days for links below: specialDays[x]=['month_number', 'date_number', 'year_number', 'link', 'optional_target']
specialDays[0]=['12', '25', '2005', 'http://www.google.com/', '_blank']
specialDays[1]=['1', '1', '2006', 'http://www.dynamicdrive.com/']

and change this


if ([mi+1]==specialDays[i_tem][0]&&[i-offsetD+1]==specialDays[i_tem][1]){
calA[i].innerHTML='<a href="'+([mi+1].toString(10).length<2? '0'+[mi+1] : [mi+1] )+([i-offsetD+1].toString(10).length<2? '0'+[i-offsetD+1] : [i-offsetD+1])+cal_y.innerHTML+'.htm">'+[i-offsetD+1]+'</a>';
break
}

to:


if ([mi+1]==specialDays[i_tem][0]&&[i-offsetD+1]==specialDays[i_tem][1]&&cal_y.innerHTML==specialDays[i_tem][2]){
calA[i].innerHTML='<a href="' + specialDays[i_tem][3] + '"' + (specialDays[i_tem][4]? ' target="' + specialDays[i_tem][4] + '"' : '') + '>'+[i-offsetD+1]+'</a>';
break
}

centipede
08-03-2017, 07:31 PM
Works exactly how it should, thank you.

jscheuer1
08-03-2017, 08:29 PM
Great! I'm not sure if you would want/need this, or maybe someone else reading here would, we can make it so that the year is optional, so that if instead of a year, you could put 'all' and that would make that special date active in that month for all years, ex:


var specialDays=new Array()
// set special days for links below: specialDays[x]=['month_number', 'date_number', 'year_number', 'link', 'optional_target']
specialDays[0]=['12', '25', '2005', 'http://www.google.com/', '_blank']
specialDays[1]=['1', '1', 'all', 'http://www.dynamicdrive.com/']

To make that work, we would need to make that other part like so:


if ([mi+1]==specialDays[i_tem][0]&&[i-offsetD+1]==specialDays[i_tem][1]&&(specialDays[i_tem][2]=='all'||cal_y.innerHTML==specialDays[i_tem][2])){
calA[i].innerHTML='<a href="' + specialDays[i_tem][3] + '"' + (specialDays[i_tem][4]? ' target="' + specialDays[i_tem][4] + '"' : '') + '>'+[i-offsetD+1]+'</a>';
break
}

centipede
08-12-2017, 06:41 PM
Weird problem, maybe it has to do with an update or something. But the arrows to change the month/year are now gone. Anyway to fix this?

centipede
08-12-2017, 07:02 PM
another thing: I can still click the arrows to change the month or year, but they are invisible.

jscheuer1
08-12-2017, 08:05 PM
I think I would need a link to your problem page to investigate.