I got it figured out folks!
Here is my JavaScript (using Script.aculo.us):
var currentRecord = 1;
function showMoreLink(obj){
//obj = document.getElementById(obj);
window.setTimeout('Effect.Appear(\'view-more\')',700);
}
Event.observe(window, 'load', init, false);
function init() {
getCount();
showTestimony();
Effect.Appear('testimony');
};
function getCount(){
new
Ajax.Request('tags/nextTestimony.cfm?action=getCount&count='+currentRecord,
{
method:'get',
onComplete: function(response) {
currentRecord = (response.responseText);
}
});
}
function showTestimony(){
new
Ajax.Updater('testimony','tags/nextTestimony.cfm?action=showNext&count='+currentRecord,{method:'get'});
}
function showNextTestimony(obj){
getCount();
showTestimony();
Effect.BlindDown('testimony');
}
Here is my ColdFuison:
<cfscript>
switch(url.action){
case "getCount":
getCount(url.count);
break;
case "showNext":
showNext(url.count);
break;
}
</cfscript>
<cffunction name="getCount" output="true" access="public">
<cfargument name="count" required="yes">
<cfset var getTestimonies = "" />
<!--- do a query to get max record id --->
<cfquery name="getLastRecord" datasource="berrettdb"
cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#">
SELECT id
FROM testimony
ORDER BY id DESC
LIMIT 1
</cfquery>
<!--- check if count variable is greater than last record id [if yes
then set count to 1 to start over, otherwise increment count by 1]
--->
<cfif arguments.count GTE getLastRecord.id>
<cfset arguments.count = 1 />
<cfelse>
<cfset arguments.count = arguments.count + 1 />
</cfif>
<cfoutput>#arguments.count#</cfoutput>
</cffunction>
<cffunction name="showNext">
<cfargument name="count" required="yes">
<cfset var getTestimony = "" />
<!--- get single testimony starting at record number passed in and
limit to just that record --->
<cfquery name="getTestimony" datasource="berrettdb">
SELECT id, content, name
FROM testimony
WHERE id = <cfqueryparam
cfsqltype="cf_sql_numeric"
value="#arguments.count#" />
LIMIT 1;
</cfquery>
<!--- output testimony and citation name for blockquote innerHTML --->
<cfoutput><p>#getTestimony.content#</p><cite>#getTestimony.name#</cite></cfoutput>
</cffunction>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---