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 conn, connString, sqlSearchCustomers, rsSearchCustomers, searchCustomers, dueDate, diffDate, fineOwed, checkedInDate, dueCheckDiffDate, intDisplayCountNo
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 = 1) then
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 <= intEndPoint) then%>
<%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 > intEndPoint) then
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 isFirstPage) then
%>
<input type="Submit" value="Previous" name="Previous" class="button"/>
<%
end if
if(not isLastPage) then
%>
<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
%>