Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

Coldfusion Scrolling Text

Hi i was wondering if anyone could help me!

im trying to create a scrolling news section on our home page, the code needs to read the news headline from the database though and it will vertically move the news items up and if the user clicks on an item it will take them to the detail page.  when the scroller is finished it would need to start automatically.

i seem to find ones that are all static text within the javascript function.

Thanks in advance
0
admoortown
Asked:
admoortown
1 Solution
 
erikTsomikSystem Architect, CF programmer Commented:
0
 
duncancummingCommented:
You can use Coldfusion to populate the javascript string.

e.g.
<cfquery name="getNews" datasource="dsn">
SELECT ID, Title
FROM News
</cfquery>

<script type="text/javascript">
<cfoutput>var jsNews = new Array(#getNews.RecordCount#);</cfoutput>
<cfoutput query="getNews">
 var arrayLine = new Array(2);
 arrayLine[0] = #GetNews.ID#;
 arrayLine[1] = #GetNews.Title#;
 jsNews[#getNews.CurrentRow#] = arrayLine;
</cfoutput>
</script>

That code's a bit of a mess, but basically you're using cfoutput to populate javascript variables.  I've done the above as a 2D array, but you can do it however you need to for your javascript to do the scrolling text to work.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now