User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 426,020 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,672 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 1047 | Replies: 8 | Solved
Reply
Join Date: Nov 2007
Posts: 44
Reputation: nish88 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

navigation button

  #1  
Jul 14th, 2008
have anyone ever creates navigation buttons such as next,previous in coldfusion?

can i see ours if you have created one?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Posts: 70
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

  #2  
Jul 14th, 2008
Based on query data? If so yes, but I don't have it with me at the moment. I'll get back to you.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: nish88 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

  #3  
Jul 15th, 2008
ya its based on query.
so thanks in advance..
Reply With Quote  
Join Date: Feb 2008
Posts: 70
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

  #4  
Jul 15th, 2008
Are you permitted by your hosting company to use custom tags?
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: nish88 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

  #5  
Jul 16th, 2008
ya am permitted
Reply With Quote  
Join Date: Feb 2008
Posts: 70
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

  #6  
Jul 16th, 2008
OK. I have a custom tag that will pretty much do everything for you. I'll post it in the morning when I get back to work.
Reply With Quote  
Join Date: Feb 2008
Posts: 70
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

  #7  
Jul 16th, 2008
Here goes. There's a lot here, so bear with me. This is actually two custom tags. One to set the variables and one to create the links.

Here is the first custom tag:

  1. <!--- pageNumSetup.cfm --->
  2.  
  3. <cfscript>
  4. // round page number variable up
  5. function roundPageNum(number) {
  6.  
  7. var x = 0;
  8.  
  9. x = Int(number);
  10.  
  11. if(number - x neq 0) {
  12. x = x + 1;
  13. }
  14.  
  15. return x;
  16. }
  17. </cfscript>
  18.  
  19. <!--- Set Default values --->
  20. <cfparam name="Caller.startRow" default="1">
  21. <cfparam name="Caller.nextPage" default="">
  22. <cfparam name="Caller.prevPage" default="">
  23. <cfparam name="Caller.numPerPage" default="20">
  24. <cfparam name="Caller.numPages" default="0">
  25. <cfparam name="Caller.curPage" default="1">
  26. <cfparam name="Attributes.queryName" default="">
  27.  
  28. <!--- Set values for previous and next pages --->
  29. <cfset Caller.nextPage = Caller.startRow + Caller.numPerPage>
  30. <cfset Caller.prevPage = Caller.startRow - Caller.numPerPage>
  31.  
  32. <!--- Determine the total number of pages for this search --->
  33. <cfset Caller.numPages = Attributes.queryName.RecordCount / Caller.numPerPage >
  34. <cfset Caller.numPages = roundPageNum(Caller.numPages)>
  35. <cfset Caller.curPage = ((Caller.startrow -1) / Caller.numPerPage) + 1>

Now for the navigation links:

  1. <!--- pageNum.cfm --->
  2.  
  3. <!--- Set Default values --->
  4. <cfparam name="Caller.startRow" default=""> <!--- Numeric --->
  5. <cfparam name="Caller.nextPage" default=""> <!--- Numeric --->
  6. <cfparam name="Caller.prevPage" default=""> <!--- Numeric --->
  7. <cfparam name="Caller.numPerPage" default="20"> <!--- Numeric --->
  8. <cfparam name="Caller.numPages" default=""> <!--- Numeric --->
  9. <cfparam name="Caller.curPage" default=""> <!--- Numeric --->
  10. <cfparam name="Caller.queryName" default=""> <!--- Query --->
  11. <cfparam name="Attributes.forwardImage" default=""> <!--- string --->
  12. <cfparam name="Attributes.backImage" default=""> <!--- string --->
  13.  
  14. <!--- This variable is used to direct the links to the correct template --->
  15. <cfparam name="Attributes.pageName" default="Index.cfm"> <!--- string --->
  16.  
  17. <!--- If there is only one page of results, there is no need to show links --->
  18. <cfif Attributes.queryName.RecordCount LT Attributes.numPerPage>
  19. <span class="curPage">Page 1 of 1</span>
  20. <cfelse>
  21.  
  22. <cfoutput>
  23.  
  24. <!--- If this is not the first page, show a link to the previous --->
  25. <cfif Attributes.prevPage gt 0>
  26. <a href="#Attributes.pageName#?startrow=#Attributes.prevPage#" class="pageNum"><cfif Attributes.backImage neq ""><img src="#Attributes.backImage#" border="0" /><cfelse>&lt;&lt;Previous Page</cfif></a>&nbsp;&nbsp;
  27. </cfif>
  28.  
  29. <!--- If this is the first page, show the page number without a link --->
  30. <cfif Attributes.curPage eq 1>
  31. <span class="curPage">1</span>
  32. <cfelse>
  33. <a href="#Attributes.pageName#?startRow=1" class="pageNum">1</a>
  34. </cfif>
  35.  
  36. <!--- Loop through the number of pages and create the links --->
  37. <cfloop index="LoopCount" from="2" to="#Attributes.numPages#">
  38.  
  39. <!--- If the loopcount is the current page, show the page number without a link --->
  40. <cfif LoopCount eq Attributes.curPage>
  41. <span class="curPage">#LoopCount#</span>
  42. <cfelse>
  43. <cfset pageStart = ((LoopCount - 1 ) * Attributes.numPerPage) + 1>
  44. <a href="#Attributes.pageName#?startRow=#pageStart#" class="pageNum">#LoopCount#</a>
  45. </cfif>
  46.  
  47. </cfloop>
  48.  
  49. <!--- If we are not on the last page, show a next button --->
  50. <cfif Attributes.nextPage lte Attributes.queryName.RecordCount>
  51. &nbsp;&nbsp;<a href="#Attributes.pageName#?startRow=#Attributes.nextPage#" class="pageNum"><cfif Attributes.forwardImage neq ""><img src="#Attributes.forwardImage#" border="0" /><cfelse>Next Page&gt;&gt;</cfif></a>
  52. </cfif>
  53.  
  54. </cfoutput>
  55. </cfif>

So, how do you use it? Like this:

  1. <!--- Set Default values --->
  2. <cfparam name="startRow" default="1">
  3. <cfparam name="nextPage" default="">
  4. <cfparam name="prevPage" default="">
  5. <cfparam name="numPerPage" default="20">
  6. <cfparam name="numPages" default="0">
  7. <cfparam name="curPage" default="1">
  8.  
  9. <cf_pageNumSetup queryName="qryQuery" />
  10.  
  11. <cf_pageNum forwardImage="next.gif" backImage="previous.gif" pageName="Index.cfm" />

Let me know how that works for you...
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: nish88 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

  #8  
Jul 29th, 2008
hiiii
ya the navigation button works correctly and perfectly.
thnk
Reply With Quote  
Join Date: Feb 2008
Posts: 70
Reputation: cmhampton is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

  #9  
Jul 29th, 2008
Anytime. Glad to help.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ColdFusion Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ColdFusion Forum

All times are GMT -4. The time now is 1:34 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC