Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 3rd, 2010, 08:13 AM
Authorized User
 
Join Date: Dec 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default Changing the display count for paging

Hi all

I would be grateful if someone could advise me as to how to allow the user the option of selecting from a drop down menu a number to change the displaycount. So the number of records displayed on each page when someone pages from one page to another can be changed.

Its currently hard coded. I have a drop down menu but can't use

intDisplayCount = request.form("pageList")

because that would just pull a figure as a string and I need it to be a number not a string. All that needs to be changed I think is the intDisplayCount. So there should be a way of capturing the number selected from the drop down menu and placing it into the variable intDisplayCount.

I hope this makes sense. Any advice would be appreciated.

Many thanks

Rob


PHP Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'Displays Customers and theirs books with fine paid/owed and those that still have an overdue book to be displayed in red%>
<%'
Has a search function%>
<%
Dim connconnStringsqlSearchCustomersrsSearchCustomerssearchCustomersdueDatediffDatefineOwedcheckedInDatedueCheckDiffDateintDisplayCountNo
connString 
=  "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" Server.MapPath("rltestingDB.mdb")


'Paging *************************************************************************************************************************
Dim intDisplayCount, pageNo, intLoopCount, intEndPoint, intStartPoint
intLoopCount = 1
intDisplayCount = 5
pageNo = 1

Dim isFirstPage, isLastPage
isFirstPage = false
isLastPage = false

searchCustomers = Request.Form("searchCustomers")

'
if (Request.Form("pageList")<>""then
    
'intDisplayCount = Request.Form("pageList")
'
end if

if (
Request.Form("previous")<>""then
    pageNo 
Request.Form("pageNo")
    
pageNo pageNo 1
    
if pageNo <= 0 then
    pageNo 
1
    end 
if
end if    

if (
Request.Form("Next")<>""then
    pageNo 
Request.Form("pageNo")
    
pageNo pageNo 1
end 
if

intEndPoint pageNo*intDisplayCount

intStartPoint 
intEndPoint intDisplayCount +1


if(pageNo 1then
    isFirstPage 
true
else
    
isFirstPage false
end 
if

if 
searchCustomers <> "" then
    sqlSearchCustomers 
"SELECT * FROM viewAllCustomersBooks WHERE NAME LIKE '%" searchCustomers "%'"
else
    
sqlSearchCustomers "SELECT * FROM viewAllCustomersBooks" 
end if

'Paging ends **********************************************************************************************************************


Set conn = Server.CreateObject("ADODB.Connection")
Set rsSearchCustomers = Server.CreateObject("ADODB.Recordset")
conn.Open(connString)
rsSearchCustomers.Open sqlSearchCustomers, conn
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Customer book records</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="global.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>

<%'
=(sqlSearchCustomers)%>

<
form method="post" action="searchCustomers.asp">
Search: <input type="text" name="searchCustomers" value="<%=searchCustomers%>" />
<
input type="submit" value="Submit" />
</
form>



<
table width="800" border="0">
<
tr>
<
th>Name</th>
<
th>Book</th>
<
th>Taken Out</th>
<
th>Due Date</th>
<
th>Fine paid/owed</th>
</
tr>
<%do while(
rsSearchCustomers.eof false)%>
    <%if (
intLoopCount >= intStartPoint and intLoopCount <= intEndPointthen%>
        <%
dueDate rsSearchCustomers("DUE_DATE")%>
        <%
checkedInDate rsSearchCustomers("CHECKED_IN_DATE")%>
        <
tr>
        <%If 
dueDate checkedInDate then
            diffDate 
DateDiff("d",dueDate,checkedInDate)
            
fineOwed diffdate*00.20%>
        <
td><%=rsSearchCustomers("NAME")%></td>
        <
td><%=rsSearchCustomers("TITLE")%></td>
        <
td><%=rsSearchCustomers("CHECKED_OUT_DATE")%></td>
        <
td><%=rsSearchCustomers("DUE_DATE")%></td>
        <
td><%response.Write(FormatCurrency(fineOwed))%> <%=(" Paid")%></td>
        <% 
        ElseIf (
dueDate<Date()) or (checkedInDate ""Then
            diffDate 
DateDiff("d",dueDate,Date())
            
fineOwed diffdate*00.20%>
        <
td id="overDueAlert"><%= rsSearchCustomers("NAME") %></td>
        <
td id="overDueAlert"><%= rsSearchCustomers("TITLE") %></td>
        <
td id="overDueAlert"><%= rsSearchCustomers("CHECKED_OUT_DATE") %></td>
        <
td id="overDueAlert"><%= rsSearchCustomers("DUE_DATE" )%></td>
        <
td id="overDueAlert"><%= FormatCurrency(fineOwed) %></td>               
        <%
        ElseIf 
checkedInDate <> "" and checkedInDate dueDate then%>
        <
td><%=rsSearchCustomers("NAME")%></td>
        <
td><%=rsSearchCustomers("TITLE")%></td>
        <
td><%=rsSearchCustomers("CHECKED_OUT_DATE")%></td>
        <
td><%=rsSearchCustomers("DUE_DATE")%></td>
        <
td><%=("Book returned on time")%></td>
        <%Else%>
        <
td><%=rsSearchCustomers("NAME")%></td>
        <
td><%=rsSearchCustomers("TITLE")%></td>
        <
td><%=rsSearchCustomers("CHECKED_OUT_DATE")%></td>
        <
td><%=rsSearchCustomers("DUE_DATE")%></td>
        <
td><%=("Book still in date")%></td>
        <%
End if%>
        </
tr>
<%
    
end if
    
intLoopCount intLoopCount 1
rsSearchCustomers
.movenext
    
if(intLoopCount intEndPointthen
        
Exit do
    
end if
Loop

if(rsSearchCustomers.eof)then
    isLastPage 
true
end 
if


%>
</
table>

<
div>
<
p>The row is hightlight in <span class="style1">RED</span> if the book is still overdue.</p>
</
div>
<
form action="searchCustomers.asp" method="post">
    <
input type="hidden" name="pageNo" value="<%=pageNo%>" />
    <
input type="hidden" name="pageList" value="<%=intDisplayCountNo%>" />
       <
input type="hidden" name="searchCustomers" value="<%=searchCustomers%>" width="20"/>         
    <%
    if(
not isFirstPagethen
        
%>
        <
input type="Submit" value="Previous" name="Previous" class="button"/>
        <%
        
end if
    
    if(
not isLastPagethen
        
%>
        <
input type="Submit" value="Next" name="Next" class="button"/>
    <% 
End if %>
    
    <
select name="pageList">
    <
option value="<%=intDisplayCountNo=1%>">1</option>
    <
option value="<%=intDisplayCountNo=2%>">2</option>
    <
option value="<%=intDisplayCountNo=3%>">3</option>
    <
option value="<%=intDisplayCountNo=4%>">4</option>
    <
option value="<%=intDisplayCountNo=5%>">5</option>
    </
select
</
form>
</
body>
</
html>
<%
rsSearchCustomers.close
Set rsSearchCustomers 
Nothing
conn
.close
Set conn 
Nothing
%> 
 
Old January 3rd, 2010, 10:43 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please check the code below:

Code:
<%
if (Request.Form("pageList")<>"") then 
intDisplayCount = Request.Form("pageList") 
end if 
Response.Write "You selected : " & intDisplayCount & "<br/>" 
Response.Write "Selected value + 2 : " & intDisplayCount + 2 & "<br/>"
%>
HTML

Code:
<form method=post>
< select name="pageList">
< option value="5">5</option>
< option value="10">10</option>
< option value="100">100</option>
</option>
< input type=submit>
< /form>
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.

Last edited by om_prakash; January 3rd, 2010 at 10:46 PM..
 
Old January 4th, 2010, 05:06 PM
Authorized User
 
Join Date: Dec 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Dear om_prakash

Thanks very much for your help. That is close to what I was trying but your solution helped me work out where I was going wrong.

Thanks again

Rob





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
new display count query carswelljr SQL Language 9 May 7th, 2007 04:59 PM
display count results and image in webpage carswelljr SQL Language 2 April 19th, 2007 09:44 AM
Display count of rows debjanib ASP.NET 1.0 and 1.1 Professional 7 May 5th, 2006 04:13 AM
recordset paging and display resultsets in columns keyvan Classic ASP Databases 1 March 7th, 2005 07:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.