Scrolling Announcements

Multiple announcements in limited space

Page 1 of 1

2 Replies - 2225 Views - Last Post: 16 December 2008 - 02:57 PM Rate Topic: -----

#1 bpb  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 02-May 08

Scrolling Announcements

Posted 07 December 2008 - 10:40 AM

I've got a really simple ColdFusion query that pulls announcements and displays them. The code works like this:
 <h4>Announcements</h4>
	<cfquery name="Announcement" datasource="myDataSource">
	SELECT * FROM Announcements WHERE SHOW = 1 
	</cfquery>
	<cfloop query="Announcement">
	<cfoutput>
	<a href="announcements_content.cfm?id=#id#">#header#</a><br />
	#teaser#<br /><br />
	</cfoutput>
	</cfloop>

This code uses an admin backend on the website that an end user can use to add and show announcements. What I want to do is have these announcements display in a limited space and scroll upwards. Right now I've just got them in a <div> container (no tables). The effect I'm looking for is something like what's shown with this code example: http://javascript.in...al-marquee.html of a vertical marquee. However, I don't want to convert it to javascript completely because it would eliminate that back-end interface to add announcements to the page (thereby creating more work for me, the webmaster). Does this make sense? Is this something that can be done in ColdFusion?

Is This A Good Question/Topic? 0
  • +

Replies To: Scrolling Announcements

#2 CR250  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 58
  • Joined: 14-June 08

Re: Scrolling Announcements

Posted 08 December 2008 - 06:50 PM

Yes you can do it no problems.

Don't add the js into a seperate file ass it into a <script> block on your .cfm page.

Execute your query

<CFQUERY NAME="SampleQry" DATASOURCE="cfartgallery">
	Select ARTNAME, PRICE, DESCRIPTION
	From Art
</CFQUERY>

 


Then change the setupLinks function to look like this:

function setupLinks() {
  <cfloop from="1" to="#SampleQry.recordcount#" index="i">
	<cfoutput>
		arrLinks[#i-1#] = "#SampleQry['artname'][i]#";
 		arrTitles[#i-1#] = "#SampleQry['description'][i]#";
	</cfoutput>
  </cfloop>
}



Of course your values will be the Title and link you want to display in the markee.

Also note that its i-1 as cf is 1 based but js is zero based.
Was This Post Helpful? 0
  • +
  • -

#3 f150b0508  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 25
  • Joined: 02-December 08

Re: Scrolling Announcements

Posted 16 December 2008 - 02:57 PM

Give this code a try. It works great for me.



<h4>Announcements</h4>
	<cfquery name="Announcement" datasource="myDataSource">
	SELECT * FROM Announcements WHERE SHOW = 1
	</cfquery>



<marquee scrollamount="2" direction="up"  loop="infinite" height="85" width="115">
								   
<div align="center">
										

	<cfoutput query="Announcement">
	<a href="announcements_content.cfm?id=#id#">#header#</a><br />
	#teaser#<br /><br />
	</cfoutput>

										  
		</div>
</marquee>














Was This Post Helpful? 0
  • +
  • -

Page 1 of 1