Hi there,
I am trying to page through records using a little bit of java as below....my problem is not displaying the data...The first block displays correctly but the second and the third are all over the places...I have tried all sorts of formating, it's not happening....Can some one spot where I am going wrong?? Thanks
The code is listed below:
<!--- Set the defaults for the parameters --->
<CFPARAM NAME="StartRow" DEFAULT="1">
<CFPARAM NAME="PageNum" DEFAULT="1">
<!--- Select the titles. --->
<cfquery name="faqs" datasource="dns_data">
SELECT *FROM TBL_FAQ
where title='myfaq'
</cfquery>
<!--- Set the number of records to display on each page. --->
<CFSET OnEachPage=5>
<!--- Determine how many pages will be displayed. --->
<CFSET NumPages=Ceiling(faqs.RecordCount / OnEachPage)>
<STYLE TYPE="text/css">
.Vis1 {
VISIBILITY: visible;
}
.Vis2 {
VISIBILITY: hidden;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
// function to Show a page
function ShowPage(obj) {
<!--- Loop through the pages to hide the blocks. --->
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<CFOUTPUT>Page#ThisPage#Div.className="Vis2";</CFOUTPUT>
</CFLOOP>
// Show the block selected
obj.className="Vis1";
}
</SCRIPT>
</HEAD>
<BODY >
<!--- Display the current record count --->
<TABLE BORDER="0">
<!--- Begin next/previous links. --->
<!--- The links are just javascript function. --->
<!--- The 'ThisPage' variable tells the function --->
<!--- which block to display. --->
<TR>
<TD>Page:</TD>
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<CFOUTPUT>
<CFSET PageNumStart=(((ThisPage - 1) * OnEachPage) + 1)>
<TD><A HREF="javascript:ShowPage(Page#ThisPage#Div)">#ThisPage#</A></TD>
</CFOUTPUT>
</CFLOOP>
</TR>
</TABLE>
<!--- End next/previous links. --->
<!--- Loop through the number of pages and create a block
for each 'page'. --->
<CFSET StartRow=1>
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<!--- Set the end row of the current block. --->
<CFSET EndRow=StartRow + OnEachPage - 1>
<CFIF EndRow GT faqs.RecordCount>
<CFSET EndRow=faqs.RecordCount>
</CFIF>
<CFOUTPUT>
<!--- <SPAN ID="Page#ThisPage#Div"><CFIF ThisPage EQ 1>Vis1<CFELSE>Vis2</CFIF>--->
<p>
<!--- Display the current block info. --->
Now displaying page #ThisPage#, records #StartRow# to
#EndRow# of #faqs.RecordCount#.
</CFOUTPUT>
<TABLE BORDER="0" align="center" >
<!--- Begin results. --->
<TR>
<TD VALIGN="top"
COLSPAN="<CFOUTPUT>#Evaluate(NumPages + 2)#</CFOUTPUT>"></TD>
</TR>
</TABLE>
<cfoutput query="faqs" STARTROW="#StartRow#" MAXROWS="#OnEachPage#">
<table width="100%" align="center">
<tr bgcolor="###iif(currentrow MOD 2,DE('000077'),DE('000077'))#">
<td><b style="color:FFFFFF">#faqs.question#</b></td>
</tr>
<tr>
<td>#faqs.answer#</td>
</tr>
</table>
</cfoutput>
</span>
<CFSET StartRow=StartRow + OnEachPage>
</CFLOOP>
</div>
</BODY>
</HTML>
thanks
I am trying to page through records using a little bit of java as below....my problem is not displaying the data...The first block displays correctly but the second and the third are all over the places...I have tried all sorts of formating, it's not happening....Can some one spot where I am going wrong?? Thanks
The code is listed below:
<!--- Set the defaults for the parameters --->
<CFPARAM NAME="StartRow" DEFAULT="1">
<CFPARAM NAME="PageNum" DEFAULT="1">
<!--- Select the titles. --->
<cfquery name="faqs" datasource="dns_data">
SELECT *FROM TBL_FAQ
where title='myfaq'
</cfquery>
<!--- Set the number of records to display on each page. --->
<CFSET OnEachPage=5>
<!--- Determine how many pages will be displayed. --->
<CFSET NumPages=Ceiling(faqs.RecordCount / OnEachPage)>
<STYLE TYPE="text/css">
.Vis1 {
VISIBILITY: visible;
}
.Vis2 {
VISIBILITY: hidden;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
// function to Show a page
function ShowPage(obj) {
<!--- Loop through the pages to hide the blocks. --->
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<CFOUTPUT>Page#ThisPage#Div.className="Vis2";</CFOUTPUT>
</CFLOOP>
// Show the block selected
obj.className="Vis1";
}
</SCRIPT>
</HEAD>
<BODY >
<!--- Display the current record count --->
<TABLE BORDER="0">
<!--- Begin next/previous links. --->
<!--- The links are just javascript function. --->
<!--- The 'ThisPage' variable tells the function --->
<!--- which block to display. --->
<TR>
<TD>Page:</TD>
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<CFOUTPUT>
<CFSET PageNumStart=(((ThisPage - 1) * OnEachPage) + 1)>
<TD><A HREF="javascript:ShowPage(Page#ThisPage#Div)">#ThisPage#</A></TD>
</CFOUTPUT>
</CFLOOP>
</TR>
</TABLE>
<!--- End next/previous links. --->
<!--- Loop through the number of pages and create a block
for each 'page'. --->
<CFSET StartRow=1>
<CFLOOP FROM="1" TO="#NumPages#" INDEX="ThisPage">
<!--- Set the end row of the current block. --->
<CFSET EndRow=StartRow + OnEachPage - 1>
<CFIF EndRow GT faqs.RecordCount>
<CFSET EndRow=faqs.RecordCount>
</CFIF>
<CFOUTPUT>
<!--- <SPAN ID="Page#ThisPage#Div"><CFIF ThisPage EQ 1>Vis1<CFELSE>Vis2</CFIF>--->
<p>
<!--- Display the current block info. --->
Now displaying page #ThisPage#, records #StartRow# to
#EndRow# of #faqs.RecordCount#.
</CFOUTPUT>
<TABLE BORDER="0" align="center" >
<!--- Begin results. --->
<TR>
<TD VALIGN="top"
COLSPAN="<CFOUTPUT>#Evaluate(NumPages + 2)#</CFOUTPUT>"></TD>
</TR>
</TABLE>
<cfoutput query="faqs" STARTROW="#StartRow#" MAXROWS="#OnEachPage#">
<table width="100%" align="center">
<tr bgcolor="###iif(currentrow MOD 2,DE('000077'),DE('000077'))#">
<td><b style="color:FFFFFF">#faqs.question#</b></td>
</tr>
<tr>
<td>#faqs.answer#</td>
</tr>
</table>
</cfoutput>
</span>
<CFSET StartRow=StartRow + OnEachPage>
</CFLOOP>
</div>
</BODY>
</HTML>
thanks