• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

How to run a coldfusion template continuously

How do a display 4 pages one page at a time and continuously in coldfusion?
0
SonnyRey
Asked:
SonnyRey
  • 3
  • 3
  • 2
  • +3
1 Solution
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
well did not under stood ur question properly

two ways:

random way


<cfquery name="pages">
select * from pages
</cfquery>

<cfset all = randRange(1,pages.recordcount)>
<cfoutput>#all#</cfoutput>


now if you save pages info in the database this works that way:

if you have a list like this

<cfset allpages = "abc.cfm,bbb.cfm,qqq.cfm,nnn.cfm">
<cfset randpage = randRange(1,#allpages#)>
<cflocation url="#randpage#">

So everytime it will locate to page which it finds randomly

Let us know if something else
0
 
ZvonkoSystems architectCommented:
You want to display: page1.cfm -> page2.cfm -> page3.cfm ->page4.cfm -> page1.cfm ->...

Right?

What time delay do you want for each page to be the display in seconds?

0
 
SonnyReyAuthor Commented:
That's exactly what I wanted to do.
About 10 seconds delay per page display.
I want to put the delay (seconds) in a table.
Thanks.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
SonnyReyAuthor Commented:
That's exactly what I wanted to do. Go from page to page
and back to the first page with a fixed time delay in seconds.
page1.cfm -> page2.cfm -> page3.cfm ->page4.cfm -> page1.cfm ->...
About 10 seconds delay per page display.  I need to run this
continuously all day. I want to put the delay (seconds) in a table.
Thanks
0
 
azadisaryevCommented:
here's how you could do it using session var (see attached code).

some notes:
- make sure session management is enabled in your application (i.e. you have sessionmanagement="yes" in your Application.cfc/cfm)
- save the cfc as test.cfc in the same folder as page1.cfm and page2.cfc
- javascript uses jquery library (http://jquery.com/). the library is loaded from google APIs cdn.
- load page1.cfm in your browser, then toggle the div display by clicking on the 'show/hide' button. now click the 'go to page 2' link - the div on page2 will be in the same state you left it on page1

Azadi
<!--- the cfc. save it as test.cfc in the same folder as cfm pages --->
<cfcomponent output="no">
	<cffunction name="setDivState" access="remote" returntype="void">
		<cfargument name="state" type="boolean" required="no" default="0">
		<cflock scope="session" timeout="2" type="exclusive">
			<cfset session.divState = arguments.state>
		</cflock>
	</cffunction>
</cfcomponent>

<!--- page1.cfm --->
<cfparam name="session.divState" default="0"><!--- cfparam our session var --->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	var flip = <cfoutput>#session.divState#</cfoutput>; // set flip var to current value of session.divState var
	if (flip % 2 == 1) $("#seasondata").css('display', 'block'); // set initial display of our div based on session var value
	$("#toggleDiv").click(function(){ // bind this to clikc event of the button
		$("#seasondata").toggle(flip++ % 2 == 0); // toggle our div based on value of flip var
		$(this).attr('value', ((flip % 2 == 0) ? 'Show' : 'Hide') + ' Div'); // change the text displayed on the button
		$.get('test.cfc?method=setDivState&state='+(flip % 2)); // call the setDivState() method of our cfc via ajax to set session var value
	})
});
</script>
<h1>Page 1</h1>
<h3><a href="page2.cfm">Go to Page 2</a></h3>
<input type="button" id="toggleDiv" value="<cfif session.divState eq 0>Show<cfelse>Hide</cfif> Div" />
<br />
<br />
<div id="seasondata" style="border:1px solid black; background-color:#f0f0f0; text-align:center; display:none">
<p>This is a div you can show/hide</p>
</div>

<!--- page2.cfm --->
it is exactly the same as page1.cfm, just change the <h1> text to Page 2 and the link to point back to page1.cfm

Open in new window

0
 
azadisaryevCommented:
oops! sorry guys - posted answer in the wrong question!!!

Azadi
0
 
andrewlorienCommented:
It's really a javascript question - the server can't force a page refresh, only the browser can.  

here's the concept:  at the top of the page, you get the delay (and the list of pages or whatever) from your database.  then write a javascript function which replaces the current page with the next page after the delay.  it might be nice to add a timer on the page too, so your users don't get confused when the page suddenly flicks over.

<CFQUERY
    get delay between pages

<SCRIPT LANGUAGE="JAVASCRIPT">
    setTimeout to call a window.location function after the delay
0
 
_agx_Commented:
(no points...)

> I need to run this continuously all day.

Something's not adding up here.  What do these pages do and where should they be "running all day"? It wouldn't make sense for a user page, because the user's browser would have to remain open all day.  It sounds more like you may be talking about running background tasks ...? If so, those would be a run on the server as a scheduled task.  You create a task. Schedule it to run every x intervals (second, hours, etc..) and it runs unattended.  Is that what you're trying to do?

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_11.html
0
 
SonnyReyAuthor Commented:
It will run on a monitor in an off track station.  It will display the dividends of a horse racing event.
Page 1 is Exacta Dividends, Page 2 is Daily Double dividends, Page 3 are win/plac/show dividends,
then back to page1.
0
 
andrewlorienCommented:
javascript is the only way to force the client to switch pages.

settimeout('window.location = #nextURL#', '#delayMilliseconds#');
0
 
ZvonkoSystems architectCommented:
In the page header you can use META REFRESH:

<meta http-equiv="refresh" content="10; URL=/your/path/page2.cfm" >

0
 
ZvonkoSystems architectCommented:
And to fetch it from a table then best fetch the value in Application.cfm and use it in meta tag as variable.
Next page also can be hard coded or based on current page lookup the successor page name from a table and use it from an Session variable.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now