Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Pages: [1] 2   Go Down
Print
Author Topic: Mouseover swap display  (Read 820 times)
0 Members and 1 Guest are viewing this topic.
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: December 31, 2003, 03:33:00 PM »

Alright, this code is a bit messy but you'll get the idea. Basically, I'm trying to create a template using a mini calendar so that when you move your mouse over a day with an event, it will display the event info of that day below the calendar, then if you move your mouse over another day it will swap the text under the calendar with those days events.

What I have so far is a mini calendar that when you move your mouse over an day, it displays the events for the whole month, instead of the day. I've tried all sorts of different approaches, but obviously it's staring me in the face and I'm just not seeing it.

Here is how the current template looks...
(move the mouse over a day with an event to display the info under the calendar)
http://216.194.96.172/cgi-bin/calendar.pl?template=test.html

here is the code I'm using right now...

==========================

<html>
<head>
<title>Calendar</title>
</head>
<body>

<script>
var linktext=new Array()
linktext[0]=" <% &getEvents( { 'range'=>'month' } ); %> <%FOREACH EVENT%> <%=$DAY->{'datestring'}%> <%= SCHEDULE FIELD(date) %><br> <%= EVENT FIELD(title) %><br><%= EVENT FIELD(description) %><br><%/FOREACH%>"

var ns6=document.getElementById&&!document.all
var ie=document.all

function show_text(thetext, whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=linktext[thetext]
else if (ns6) document.getElementById(whichdiv).innerHTML=linktext[thetext]
}

function resetit(whichdiv){
if (ie) eval("document.all."+whichdiv).innerHTML=' '
else if (ns6) document.getElementById(whichdiv).innerHTML=' '
}

</script>

<center><font face=verdana>
<% &getEvents( { 'range'=>'month' } ); %>
<TABLE BORDER="1">
<TR>
<TH CLASS="thinborder" NOWRAP ALIGN="RIGHT" COLSPAN="7" bgcolor="#C0C0C0">
<%=$MONTH_NAME%> <%=$YEAR%></TH></TR>
<TR>
<%FOREACH GRID COLUMN%>
<% $d=0; %>
<TH CLASS="thinborder" BGCOLOR="<%=$_COLUMN_HEADER_BGCOLOR%>">
<SPAN CLASS="columnheader"><font size="1"><%= $DAY_ABBREVIATIONS->[$COL] %></SPAN></TH>
<%$d++;%>
<%/FOREACH%></TR>
<%FOREACH GRID ROW%>
<TR>
<%FOREACH GRID COLUMN%>
<% $i=0; %>
<a href="<%=$CGI_URL_QUERYSTRING%>selected_datestring=<%=$DAY->{'datestring'}%>&datestring=<%=$DAY->{'datestring'}%>&view=Day" CLASS="griddatetext" >
<TD BGCOLOR="<%IF SELECTED%>#F7F2D7<%ELSE%><%IF EVENTS EXIST%>#CC9999<%/IF%><%/IF%>" CLASS="thinborder" VALIGN=TOP width="24" height="20" <%IF EVENTS EXIST%> onMouseover="show_text(0,'div1')", style.backgroundColor='<%IF SELECTED%>#F7F2D7<%ELSE%><%IF EVENTS EXIST%>#CC9999<%/IF%><%/IF%>', style.fontWeight='normal'" <%/IF%>>
<%IF DISPLAY%>
<font size="1"><SPAN BGCOLOR="<%=$_GRID_DATE_BGCOLOR%>" STYLE="background-color:<%=$_GRID_DATE_BGCOLOR%>"> <NOBR>
<%if($DAY->{'dd'}==1&&$VIEW ne "Month"){%><%=$DAY->{''}%> <%}%><%=$DAY->{'dd'}%></NOBR></SPAN><br>
<%FOREACH EVENT%>
<%$i++;%>
<%IF EVENTS EXIST%>
<font size="1"><span style="background-color: #ffffff"><A CLASS=SELECT HREF="<%=$CGI_URL_QUERYSTRING%>selected_datestring=<%=$DAY->{'datestring'}%>&datestring=<%=$DAY->{'datestring'}%>&view=Day" CLASS="griddatetext"></a><%/FOREACH%>
</span>
<%/IF%>
<%/IF%>
</TD></a>
<%/FOREACH%>
</TR>
<%/FOREACH%>
</TABLE>
<span id="div1">text appears here </span>
</CENTER>
</body>
</html>

===========================


So that's where I stand. Basically, what I've been playing around with is this part:

linktext[0]=" <% &getEvents( { 'range'=>'month' } ); %> <%FOREACH EVENT%> <%=$DAY->{'datestring'}%> <%= SCHEDULE FIELD(date) %><br> <%= EVENT FIELD(title) %><br><%= EVENT FIELD(description) %><br><%/FOREACH%>"


I'm sure it's obvious what I need to do, but my mind is blanking. Any input would be awesome.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: December 31, 2003, 05:39:00 PM »

It looks like you're defining the only one JavaScript variable (linktext[0]) with the data for the whole month with the line starting:

linktext[0]=" <% &getEvents( { 'range'=>'month' } ); %>

You'll have to make a separate JavaScript variable to hold the event text for each day, load that data into separate variables and then call the appropriate variable from the particular date.

Dan O.

------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: December 31, 2003, 06:07:00 PM »

That totally makes sense. However the actual code and variables I need to use are what I'm unsure about. The javascript was a piece of code I grabbed off another website and modified it to try and make it work here.
So...hmm...do I just make something like this?

linktext[0]=" <% &getEvents( { 'range'=>'month' } ); %>
linktext[1]=" <% &getEvents( Huh? ); %>

If you can't already tell, I'm trying to learn all this as I go.

Thanks again for your help man.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: December 31, 2003, 07:17:00 PM »

I'm afraid I can't give you the exact code to use without doing it myself but it would likely need to be something like :

<script>
var linktext=new Array()

<% &getEvents( { 'range'=>'month' } ); %>
<%FOREACH EVENT%>
linktext[$DAY->{'dd'}] .= " <%= EVENT FIELD(title) %><br><%= EVENT FIELD(description) %><br>
<%/FOREACH%>"

(take special note of the .= in stead of just = in the line above.)

Than called in the calendar HTML code something like:

onMouseover="show_text($DAY->{'dd'},'div1')",

Maybe that will set you on the right track?

Dan O.


[This message has been edited by DanO (edited December 31, 2003).]

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #4 on: January 01, 2004, 12:45:00 PM »

Thanks again DanO  

I've been playing around with the code you suggested but still havnt been able to get it working.

Is there perhaps another way to achieve the same effect using another method? Dynamically maybe? I think it would make a neat template if it worked. heh.

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: January 01, 2004, 04:37:00 PM »

** Is there another way to achieve the same effect using another method? Dynamically maybe? **

What you're attempting is dynamic. You could pass the whole discription to the function from the link instead or putting them into an array although I don't know off hand how you'd get more than one event's description to pass to that function. Have you tried looking at the code from the previous forum message "ToolTip Template"?

** I've been playing around with the code you suggested but still havnt been able to get it working. **

What is it that's happening?? (hint: post a link to what you've got so far)

Dan O.


------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: January 02, 2004, 07:50:00 AM »

"Have you tried looking at the code from the previous forum message "ToolTip Template"?"

heh. Yeah. I was the one who made that template actually  
I tried to adapt it but couldnt find a way how.

"What is it that's happening?? (hint: post a link to what you've got so far)"

Well, when I change the code such as you suggested, when the mouse rolls over a day with an event, nothing happens. No errors, no nothing. It does not swap out any text anywhere. I tried several variations on what you suggested without any luck. It SEEMS like it's the right idea, but something is still not right.

Just curious, you mentioned earlier "(take special note of the .= in stead of just = in the line above.)"

I tried that both ways and it didnt make a difference. What does the "." do?

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #7 on: January 02, 2004, 10:21:00 AM »

here is more ot add in case it helps.

When I have the code like this:

=================

var linktext=new Array()
<% &getEvents( { 'range'=>'month' } ); %>
linktext[<%FOREACH EVENT%><%= SCHEDULE FIELD(start_time) %><%= EVENT FIELD(title) %><%= EVENT FIELD(description)

%><%/FOREACH%>] .="  <%FOREACH EVENT%><%=$DAY->{'datestring'}%> <%= SCHEDULE FIELD(date) %><br> <%= EVENT FIELD(title)

%><br><%= EVENT FIELD(description) %><br><%/FOREACH%>"

=============

Then later I have this:

=============

<%IF EVENTS EXIST%> ONMOUSEOVER="show_text(<%FOREACH EVENT%><%= SCHEDULE FIELD(start_time) %><%=

EVENT FIELD(title) %><%= EVENT FIELD(description) %><%/FOREACH%>,'div1')"<%/IF%>

=============

It generates something interesting. If I look at the code of the generated HTML page, it loads all the months events into the linktext and if you scroll down the code to look at the individual days with events that are generated, it correctly shows ONLY those days events for the mouseover. However it's still not having the desired result. It seems like it's so close...and yet....

Here is a link to the template I'm talking about if you wan to view the source code to see what I mean: http://216.194.96.172/cgi-bin/calendar.pl?template=test2.html


------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #8 on: January 02, 2004, 12:17:00 PM »

** No errors, no nothing. **

The page code that is produced is what is important to finding what's going on and is why I suggested you post a link to it (if not each variation you've tried). A link to a text version of template(s) being used for each might be necessary as well.

** What does the "." do? **

".=" is essentually "+=" but for strings.

** linktext[<%FOREACH EVENT%><%= SCHEDULE FIELD(start_time) %><% ... **

That is definitely not going to work as linktext[] is expecting an array reference (number) to go between the [].

Dan O.

BTW. The code I posted has an " in the wrong place, instead of

... ><br>
<%/FOREACH%>"

it should be more like:

... ><br>"
<%/FOREACH%>

But still might not be the exact code required to get it working,

------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: January 02, 2004, 12:51:00 PM »

"BTW. The code I posted has an " in the wrong place"

Well, it's ALMOST there. I can smell it. http://216.194.96.172/cgi-bin/calendar.pl?template=test.html

The page code results show this:

==============
linktext[$DAY->{'dd'}] .= "Example Event 1"
linktext[$DAY->{'dd'}] .= "Example Event 2"
linktext[$DAY->{'dd'}] .= "Example Event 3"
==============

What seems to not be happening is that the numbers are not being generated using the $DAY->{'dd'} part of the code. The events are being generated, but the numbers (dates) are not.

hmm.

------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: January 02, 2004, 02:53:00 PM »

Aside from the problem above, I'm going to run into another problem, right? If there are multiple events on one day, then it wont correctly show all the events on that day because the array will be assigning it the same number.

hmm. should I just give up?

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #11 on: January 02, 2004, 03:30:00 PM »

 
quote:
The page code results show this:

==============
linktext[$DAY->{'dd'}] .= "Example Event 1"
linktext[$DAY->{'dd'}] .= "Example Event 2"
linktext[$DAY->{'dd'}] .= "Example Event 3"
==============


I forget about $DAY->{'dd'} being a template variable. it will have to be:

linktext[<%$DAY->{'dd'}%>] ...

The same for where it is used on the mouse over. <%$DAY->{'dd'} %>

quote:
If there are multiple events on one day, then it wont correctly show all the events on that day because the array will be assigning it the same number.
That's what the ".=" is for, adding all the event details from the same day together.

Dan O.

------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: January 02, 2004, 03:33:00 PM »

When I use

onMouseover="show_text(<%=$DAY->{'dd'}%>,'div1')"

It correctly shows the day number. But when I use the same piece of code

and put it into:

linktext[<%=$DAY->{'dd'}%>]

It no longer works. I was just trying to modify the example you gave of:

linktext[$DAY->{'dd'}]


It seems like it has something to do with being inbetween the brackets of the linktext[]
As soon the code is put in there it no longer functions as proper code. Is this just a silly syntax thing?

------------------

Logged
SoulBoy
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #13 on: January 02, 2004, 03:37:00 PM »

I forget about $DAY->{'dd'} being a template variable. it will have to be:

linktext[<%$DAY->{'dd'}%>] ...

The same for where it is used on the mouse over. <%$DAY->{'dd'} %>

================================

Ah-ha. Using that generates an error however.


syntax error at (eval 1) line 6, near "}print" syntax error at (eval 1) line 21, near "}print"

It hilights this code:

print "\nlinktext[";$DAY->{'dd'}print "] .= \" "; print $EVENT->{details}->{title};print "<br>";print $EVENT->{details}->{description};print "<br>\"";}

I'm still looking at it trying to figure it out.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #14 on: January 02, 2004, 04:49:00 PM »

** Using that generates an error however **

I need to see the actual template code which is causing the problem before I can suggest anything further. Maybe you could like directly to the template in question otherwise you'll have to copy it, change the file name extension to .txt and like to it.

Dan O.

------------------

Logged
Pages: [1] 2   Go Up
Print
Jump to: