Solved

Select menu in DB paging script

Posted on 2002-05-06
17
194 Views
Last Modified: 2012-06-27
Hello,

I have borrowed the following script from another source:

% @ LANGUAGE="VBScript" %>
% Option Explicit %>
%
Response.Expires = 0
Response.Buffer = True
Server.ScriptTimeout = 360
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1

Dim cmdDC, RecordSet, DataConnection, CommandText

DataConnection = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("demo.mdb")
Set cmdDC = Server.CreateObject("ADODB.Connection")
cmdDC.Open DataConnection
%>
html>
head>/head>
body>
%
Dim recPage, numPages, numRecs, pageSize

'Get the page number we need to display from QueryString
recPage = CInt(Request.Querystring("page"))
If recPage=0 Then recPage=1

'Get the requested number of records per page
pageSize = CInt(Request.Querystring("recs"))
If pageSize = 0 Then pageSize = 10 'If we aren't given a value use 10

'The code we need to set up a recordset object for paging
Set RecordSet = Server.CreateObject("ADODB.RecordSet")
RecordSet.PageSize = pageSize
RecordSet.CacheSize = pageSize 'This is optional
RecordSet.CursorLocation = adUseClient

'Open the recordset
CommandText = "SELECT * FROM Table1"
RecordSet.Open CommandText, cmdDC, adOpenForwardOnly, adLockReadOnly, adCmdText

'Get the number of pages and records
numPages = RecordSet.PageCount
numRecs = RecordSet.RecordCount

'Just in case we have a bad request
If recPage > numPages Then recPage = numPages
If recPage  1 Then recPage = 1

'Set the page we want to display
RecordSet.AbsolutePage = recPage

'Write out the total number of records in the recordset
Response.Write("P> B>" & numRecs & " records found./B>" )
'Write out the current page number and total number of pages
Response.Write("BR> Page " & recPage & " of " & numPages & "/P>")

'Write out the records contained in this page
Dim i
For i=1 To pageSize
If NOT RecordSet.EOF Then
Response.Write(RecordSet("Name") & " | " & RecordSet("Data") & " BR>")
RecordSet.MoveNext
End If
Next

'Clean up
RecordSet.Close
cmdDC.Close
Set RecordSet = Nothing
Set cmdDC = Nothing
%>

form name="recsform" action="paging.asp" method="get">
Show
select name="recs" onchange="updateBoxes(recsform)">
option value="10">10
option value="25">25
option value="50">50
option value="100">100
/select>
records per page




Display page
select name="page">
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
/select>




input type="submit" value="GO">

/form>

SCRIPT LANGUAGE="JavaScript">
!--
NUM_RECORDS = %=numRecs%>;
function updateBoxes(theFormObj)
{
var selectedRecs = theFormObj.recs.options[theFormObj.recs.selectedIndex].value;
var numpages = Math.ceil(NUM_RECORDS / selectedRecs);
var numOptions = theFormObj.page.length;
for(var i=0 ; inumOptions ; i++){
theFormObj.page.options[0] = null;
}
for(var j=0 ; jnumpages ; j++){
theFormObj.page.options[j] = new Option(j+1,j+1);
}
theFormObj.page.selectedIndex = 0;
}
// -->
/SCRIPT>
SCRIPT LANGUAGE="JavaScript">
!--
updateBoxes(document.recsform);
// -->
/SCRIPT>
/body>
/html>

Basically, the problem I see with it is that in that second select menu named "page", there is no way to write "selected" to any of the options.  For example, in the other slect menu named "recs", I have added the following to each option:

<option<% If pageSize = 10 Then Response.Write " selected" End If %> value="10">10</option>

Does anybody know of anything I could do that with that second menu.  It seems to me that the select menus should "remember" your choices when you go to another page.

Any help is greatly appreciated.  Thank you.

David
0
Comment
Question by:beegled
  • 7
  • 5
  • 5
17 Comments
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
David
write this
I this method every time when u change your selection, u send an indication of what page r u using threw the url and when u get it u just ask about the  url and place selected on the right selection.

NOTE=you can replace the recordset("page") with an index going from 1-what ever

<select name="rect" onchange="javascript:submitform()">
<%do while recordset.eof=false%>
<option <%if request.queryString("id")=1 then%> selected <%end if%> value="<%=recordset("page")%>"><%=recordset("page")%></option>
<%recordset.movenext%>
<%loop%>
</select>

<script language="javascript">
function submitform(){
document.formName.action="nameofpage?id=" + document.formName.rect.options[document.formName.rect.selectedIndex].value;
document.formName.submit();
}
</script>
0
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
sorry!
if  u r using a loop or an index replace the

if request.queryString("id")=1

with

if request.queryString("id")=INDEX(like for index=1 to 20)
0
 
LVL 29

Expert Comment

by:Göran Andersson
Comment Utility
Here is how you do it:

<select name="page">
<%
For lngPage=1 to numPages
     %><option value="<%=lngPage%>"<%If lngPage=recPage Then Response.Write " selected"%>><%=lngPage%><%
Next
%>
</select>
0
 

Author Comment

by:beegled
Comment Utility
giladBoker,

I have tried your method and it did not work for me.  Perhaps I did not do it correctly but it gave me JavaScript errors.

GreenGhost,

I tried your method but then the select menu was no longer populated with any values and the page stopped processing after that so any content I had below it did not show when the page was loaded as if I had a response.end in there or something.

David
0
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
check your scripts again.

generaly you just have to send an index of where u r and get it agin.

onchange-u send the index  threw the url

and when the page is loaded u ask for this index from the url and then work with it.

shouldnt be so complicated

good luck
0
 

Author Comment

by:beegled
Comment Utility
giladBoker,

I still have not figured exactly the problem I am having with the script you gave me but now realize  am unable to use what you have given me.  The problem is that I have modified the above script a great deal and in fact am not just writing data from a DB but allowing the user to query different sets of data from the DB and am using the get method.

David
0
 
LVL 29

Expert Comment

by:Göran Andersson
Comment Utility
Check the html source code created (view source) to check for any error messages. If you get an error in the code producing the select, the error message will not show on the page as it's inside the select.

You might have to dimension the counter:
Dim lngPage

I tried this, and it sure serves up a select list with pages 1 through 10, with 5 selected:

<%
Option Explicit
Dim numPages, recPage, lngPage
numPages=10
recPage=5
%>
<select name="page">
<%
For lngPage=1 to numPages
    %><option value="<%=lngPage%>"<%If lngPage=recPage Then Response.Write " selected"%>><%=lngPage%><%
Next
%>
</select>
0
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
do u have javascript error when u load the page??

if yes its beciuse that when u load page for the first time it comes without index at the url.


u should write in the action part of the form that goes to this form and index
example
=======

if your form name is myForm.asp

u go to the form that calls him and write in his action

<form name="what ever" action="MyForm.asp?id=1">

then u eliminate the error on the load part

if u have other errors please specify it over here

good luck
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:Göran Andersson
Comment Utility
giladBoker, check the code from beegled. It gets page number and page size from the querystring, and sets default values if there is no values, so there is no need to include the values when the page is first showed.
0
 
LVL 1

Expert Comment

by:giladBoker
Comment Utility
yes i see it now GreenGhost thanks..
0
 

Author Comment

by:beegled
Comment Utility
Here is what the script looks like now:

<% @ LANGUAGE="VBScript" %>
<% Option Explicit %>
<%
Response.Expires = 0
Response.Buffer = True
Server.ScriptTimeout = 360
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1

Dim cmdDC, RecordSet, DataConnection, CommandText

DataConnection = "DRIVER=SQL Server;SERVER=server;DATABASE=db;UID=login;PWD=pass"
Set cmdDC = Server.CreateObject("ADODB.Connection")
cmdDC.Open DataConnection

Dim strProduct, strPart, strSort
strProduct = Request.Querystring("product")
strPart = Request.Querystring("parts")
strSort = Request.Querystring("sort")

If strSort = "" Then
strSort = "COMPONENT_ITEM_NUMBER ASC"
Else If strSort = "numeric asc" Then
strSort = "COMPONENT_ITEM_NUMBER ASC"
Else If strSort = "numeric desc" Then
strSort = "COMPONENT_ITEM_NUMBER DESC"
Else If strSort = "alpha asc" Then
strSort = "COMPONENT_ITEM_DESCRIPTION ASC"
Else If strSort = "alpha desc" Then
strSort = "COMPONENT_ITEM_DESCRIPTION DESC"
End If
End If
End If
End If
End If

Dim aProducts
aProducts = Array("product1", "product2", "product3", "product4", "product5")
%>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function sortHandler(sort){
var URL = document.sort.site.options[document.sort.site.selectedIndex].value;
window.location.href = URL;
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<p>&#160;</p>
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td><font face="arial, helvetica" size="2"><b>Select Product</b></font></td>
<td colspan="2"><font face="arial, helvetica" size="2"><b>Select Parts Type</b></font></td>
<% If (strProduct = "" OR strPart = "") OR (strProduct = "error" OR strPart = "error") Then %>
<td colspan="2"><font face="arial, helvetica" size="2"><b>Search For A Part Number</b></font></td>
<% Else %>
<td><font face="arial, helvetica" size="2"><b>Sort By</b></font></td>
<% End If %>
</tr>
<tr>
<form action="index.asp" method="get">
<td>
<select name="product">
<option<% If strProduct = "error" Then Response.Write " selected" End If %> value="error"><small>Choose
a product -&gt;</small></option>
<option<% If strProduct = "all" Then Response.Write " selected" End If %> value="all"><small>All Products</small></option>
<option<% If strProduct = "Product1" Then Response.Write " selected" End If %> value="Product1"><small>Product1</small></option>
<option<% If strProduct = "Product2" Then Response.Write " selected" End If %> value="Product2"><small>Product2</small></option>
<option<% If strProduct = "Product3" Then Response.Write " selected" End If %> value="Product3"><small>Product3</small></option>
<option<% If strProduct = "Product4" Then Response.Write " selected" End If %> value="Product4"><small>Product4</small></option>
<option<% If strProduct = "Product5" Then Response.Write " selected" End If %> value="Product5"><small>Product5</small></option>
</select>
</td>
<td valign="top">
<select name="parts">
<option<% If strPart = "error" Then Response.Write " selected" End If %> value="error"><small>Choose
a parts type -&gt;</small></option>
<option<% If strPart = "all" Then Response.Write " selected" End If %> value="all"><small>All Parts</small></option>
<option<% If strPart = "fru" Then Response.Write " selected" End If %> value="fru"><small>FRU Parts</small></option>
<option<% If strPart = "urp" Then Response.Write " selected" End If %> value="urp"><small>UR Parts</small></option>
<option<% If strPart = "optional" Then Response.Write " selected" End If %> value="optional"><small>Optional
Accessories</small></option>
</select>
</td>
<td>
<input type="submit" value="SUBMIT" onfocus="this.blur()">
</td>
</form>
<% If (strProduct = "" OR strPart = "") OR (strProduct = "error" OR strPart = "error") Then %>
<form action="results.asp" method="get">
<td>
<input type="text" size="10" maxlength="11" name="part" onfocus="if(this.value=='xxx-xxxx-xx')this.value='';"
onblur="if(this.value=='')this.value='xxx-xxxx-xx';" value="xxx-xxxx-xx">
</td>
<td>
<input type="submit" value="SUBMIT" onfocus="this.blur()">
</td>
</form>
<% End If %>
<% If NOT (strProduct = "" OR strPart = "") AND NOT (strProduct = "error" OR strPart = "error") Then
'AND NOT (numRecs = "" OR numRecs = 0)
%>
<form name="sort">
<td>
<select name="site" size=1 onchange="javascript:sortHandler()">
<option<% If strSort = "COMPONENT_ITEM_NUMBER ASC" Then Response.Write " selected" End If %> value="index.asp?product=<%=strProduct%>&parts=<%=strPart%>&sort=numeric%20asc"><small>Part
Number -&gt;<!--&#8593;--></small></option>
<option<% If strSort = "COMPONENT_ITEM_NUMBER DESC" Then Response.Write " selected" End If %> value="index.asp?product=<%=strProduct%>&parts=<%=strPart%>&sort=numeric%20desc"><small>Part
Number &lt;-<!--&#8595;--></small></option>
<option<% If strSort = "COMPONENT_ITEM_DESCRIPTION ASC" Then Response.Write " selected" End If %> value="index.asp?product=<%=strProduct%>&parts=<%=strPart%>&sort=alpha%20asc"><small>Description
A-Z</small></option>
<option<% If strSort = "COMPONENT_ITEM_DESCRIPTION DESC" Then Response.Write " selected" End If %> value="index.asp?product=<%=strProduct%>&parts=<%=strPart%>&sort=alpha%20desc"><small>Description
Z-A</small></option>
</select>
</td>
</form>
<% End If %>
<% If NOT (strProduct = "" OR strPart = "") AND NOT (strProduct = "error" OR strPart = "error") Then
%>
<form action="download.asp" method="post">
<td>
<img src='/pix/spacer.gif' width='5' height='1'>
<input type="image" value="PRINTER-FRIENDLY" src="/pix/printer_small.gif" width="16" height="16" border="0">
<input type="hidden" name="product" value="<%=strProduct%>">
<input type="hidden" name="part" value="<%=strPart%>">
</td>
</form>
<% End If %>
</tr>
</table>
<%
If strProduct = "" AND strPart = "" Then
Response.Write("<p><font face='arial, helvetica' size='2'>Select a product and parts type from the select
menus above and click &#34;submit&#34;.</font></p>")

Else If strProduct = "error" OR strPart = "error" Then
Response.Write("<p><font face='arial, helvetica' size='2'><b>You must select a product and a parts type
from the menus to generate a list.<br>You may select 'All Products' or 'All Parts' to generate a list
for all products or parts.</b></font></p>")

Else

Dim recPage, numPages, numRecs, pageSize

recPage = CInt(Request.Form("page"))
If recPage=0 Then recPage=1

pageSize = CInt(Request.Form("recs"))
If pageSize = 0 Then pageSize = 10

Set RecordSet = Server.CreateObject("ADODB.RecordSet")
RecordSet.PageSize = pageSize
RecordSet.CacheSize = pageSize
RecordSet.CursorLocation = adUseClient

If strPart = "fru" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT
AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, COMPONENT_ITEM_LONG_DESC,
SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN
ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A')
END FROM vIFC_SRV_PART_PRICE_LIST_804 WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY " & strSort
& ""

Else If strPart = "urp" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER],
[SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE
PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A'
ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_811 WHERE TOP_ITEM_NUMBER
= '" & strProduct & "' ORDER BY " & strSort & ""

Else If strPart = "optional" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER],
[SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE
PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A'
ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_812 WHERE TOP_ITEM_NUMBER
= '" & strProduct & "' ORDER BY " & strSort & ""

Else If strPart = "all" AND NOT strProduct="all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT
AMER], [ACCY AND URP DIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER,
TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO'
END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC,
'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_ALL WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY "
& strSort & ""

Else If strPart = "fru" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT
AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN
OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC))
= '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_804 ORDER
BY " & strSort & ""

Else If strPart = "urp" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER],
[SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE
PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A'
ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_811 ORDER BY " & strSort
& ""

Else If strPart = "optional" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER],
[SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE
PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A'
ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_812 ORDER BY " & strSort
& ""

Else If strPart = "all" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT
AMER], [ACCY AND URP DIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER,
TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO'
END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC,
'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_ALL ORDER BY " & strSort & ""

End If
End If
End If
End If
End If
End If
End If
End If

RecordSet.Open CommandText, cmdDC, 2, 2, 1

numPages = RecordSet.PageCount
numRecs = RecordSet.RecordCount

If recPage > numPages Then recPage = numPages
If recPage < 1 Then recPage = 1

Response.Write ("<br>")
Response.Flush

If strPart = "fru" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("<p><font face='arial, helvetica' size='2'><b>There are no FRU parts for the " & strProduct
& " at this time.</b></font></p>")

Else If strPart = "urp" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("<p><font face='arial, helvetica' size='2'><b>There are no UR parts for the " & strProduct
& " at this time.</b></font></p>")

Else If strPart = "optional" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("<p><font face='arial, helvetica' size='2'><b>There are no optional accessories for the
" & strProduct & " at this time.</b></font></p>")

Else

RecordSet.AbsolutePage = recPage

Dim i
For i = 1 To pageSize
If NOT RecordSet.EOF Then

Response.Write("<table border='0' cellpadding='3' cellspacing='0' width='100%'>")

If strSort = "COMPONENT_ITEM_NUMBER ASC" OR strSort = "COMPONENT_ITEM_NUMBER DESC" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Part Number</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'><b>" & RecordSet.Fields("COMPONENT_ITEM_NUMBER")
& "</b></font></td>")
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Description</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>" & RecordSet.Fields("COMPONENT_ITEM_DESCRIPTION")
& "</font></td>")
Response.Write("</tr>")

Else If strSort = "COMPONENT_ITEM_DESCRIPTION ASC" OR strSort = "COMPONENT_ITEM_DESCRIPTION DESC" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Description</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>" & RecordSet.Fields("COMPONENT_ITEM_DESCRIPTION")
& "</font></td>")
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Part Number</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'><b>" & RecordSet.Fields("COMPONENT_ITEM_NUMBER")
& "</b></font></td>")
Response.Write("</tr>")

End If
End If

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Returnable?</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>" & RecordSet.Fields("SEG") & "</font></td>")
Response.Write("</tr>")

End If

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>FSC/ISC Price</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU DIRECT AMER")
& ".00</font></td>")
Response.Write("</tr>")
Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>ASC Price</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU INDIRECT AMER")
& ".00</font></td>")
Response.Write("</tr>")

Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Price</b></font></td>" &_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP DIRECT
AMER") & ".00</font></td>")
Response.Write("</tr>")

Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "812" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Price</b></font></td>" &_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP DIRECT
AMER") & ".00</font></td>")
Response.Write("</tr>")

End If
End If
End If

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>List Price</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("SVC MFG LIST") & ".00</font></td>")
Response.Write("</tr>")

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" AND NOT RecordSet.Fields("SEG") = "NO"
Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Return Credit</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>$" & RecordSet.Fields("SVC RET FRUS CORE
CREDIT") & ".00</font></td>")
Response.Write("</tr>")

End If

If strPart = "all" Then

Dim strPartType
If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then
strPartType = "Field Replaceable Unit (FRU)"
Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" Then
strPartType = "User Replaceable (UR) Part"
Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "812" Then
strPartType = "Optional Accessory"
End If
End If
End If

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Part Type</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>" & strPartType & "</font></td>")
Response.Write("</tr>")

End If

If strProduct = "all" Then

Response.Write("<tr>")
Response.Write("<td width='20%'><font face='arial, helvetica' size='2'><b>Used On</b></font></td>" &_
              "<td><font face='arial, helvetica' size='2'>" & RecordSet.Fields("TOP_ITEM_NUMBER") &
"</font></td>")
Response.Write("</tr>")

End If

Response.Write("<tr>")
Response.Write("<td width='20%' valign='top'><font face='arial, helvetica' size='2'><b>Comments</b></font></td>"
&_
              "<td><font face='arial, helvetica' size='2'>" & RecordSet.Fields("COM") & "</font></td>")
Response.Write("</tr>")
Response.Write("</table>")

RecordSet.MoveNext

If NOT RecordSet.EOF Then

Response.Write("<table border='0' cellpadding='0' cellspacing='5' width='100%'>")
Response.Write("<tr>")
Response.Write("<td bgcolor='#339900' height='1' colspan='2'><img src='/pix/spacer.gif' height='1'></td>")
Response.Write("</tr>")
Response.Write("</table>")

End If

End If
Next

RecordSet.Close
cmdDC.Close
Set RecordSet = Nothing
Set cmdDC = Nothing

End If
End If
End If
End If
End If
%>
<% If NOT numRecs = "" AND NOT numRecs = 0 Then %>
<form name="recsform" action="index.asp?<%=Request.Servervariables("QUERY_STRING")%>" method="post">
<p><!--<font face="arial, helvetica" size="2"><%=numRecs%> Records</font><br>-->
<font face="arial, helvetica" size="2">Show </font>
<select name="recs" onchange="updateBoxes(recsform)">
<% If numRecs < 10 Then %>
<option value="<%=numRecs%>"><%=numRecs%></option>
<% End If %>
<% If numRecs >= 10 Then %>
<option<% If pageSize = 10 Then Response.Write " selected" End If %> value="10">10</option>
<% End If %>
<% If numRecs >= 25 Then %>
<option<% If pageSize = 25 Then Response.Write " selected" End If %> value="25">25</option>
<% End If %>
<% If numRecs >= 50 Then %>
<option<% If pageSize = 50 Then Response.Write " selected" End If %> value="50">50</option>
<% End If %>
<% If numRecs >= 100 Then %>
<option<% If pageSize = 100 Then Response.Write " selected" End If %> value="100">100</option>
<% End If %>
<% If numRecs <= 100 AND NOT numRecs < 10 Then %>
<option<% If pageSize = numRecs Then Response.Write " selected" End If %> value="<%=numRecs%>">All</option>
<% End If %>
</select>
<font face="arial, helvetica" size="2"> records per page</font><br>
<!--<font face="arial, helvetica" size="2">Page <%=recPage%> of <%=numPages%></font><br>-->
<font face="arial, helvetica" size="2">Display page </font>
<select name="page">
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select><br>
<input type="submit" value="GO" onfocus="this.blur()"></p>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!--
NUM_RECORDS = <%=numRecs%>;
function updateBoxes(theFormObj)
{
var selectedRecs = theFormObj.recs.options[theFormObj.recs.selectedIndex].value;
var numpages = Math.ceil(NUM_RECORDS / selectedRecs);
var numOptions = theFormObj.page.length;
for(var i=0 ; i<numOptions ; i++){
theFormObj.page.options[0] = null;
}
for(var j=0 ; j<numpages ; j++){
theFormObj.page.options[j] = new Option(j+1,j+1);
}
theFormObj.page.selectedIndex = 0;
}
// -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
updateBoxes(document.recsform);
// -->
</SCRIPT>
<% End If %>
<p>&#160;</p>
</BODY>
</HTML>
0
 

Author Comment

by:beegled
Comment Utility
GreenGhost and giladBoker,

I have tried both of your methods again and still with no luck.  Any ideas now that you see my whole page?

David
0
 
LVL 29

Expert Comment

by:Göran Andersson
Comment Utility
What I see from your code is:

- It's fairly well written.

- You should place all the Dim statements at the top of the page. They are all performed before any code anyway, so there is no reason to spread them throughout the page.

- The code would benefit from using ElseIf instead of Else If. For an example:

If strSort = "" Then
     ...
Else If strSort = "numeric asc" Then
     ...
Else If strSort = "numeric desc" Then
     ...
Else If strSort = "alpha asc" Then
     ...
Else If strSort = "alpha desc" Then
     ...
End If
End If
End If
End If
End If

can be replaced by:

If strSort = "" Then
     ...
ElseIf strSort = "numeric asc" Then
     ...
ElseIf strSort = "numeric desc" Then
     ...
ElseIf strSort = "alpha asc" Then
     ...
ElseIf strSort = "alpha desc" Then
     ...
End If

In this case, it can even be coded with a Select Case statement:

Select Case strSort
Case ""
     ...
Case "numeric asc"
     ...
Case "numeric desc"
     ...
Case "alpha asc"
     ...
Case "alpha desc"
     ...
End Select


I can add nothing furter. If you take the code I have posted and put it in the select list, it should work. If you remember to dimension the counter, and check that it's not already used on the page, there should be no problem.

IF you can't get it to work, I need more input, like what the error message is.
0
 

Author Comment

by:beegled
Comment Utility
I made the changed you talked about with adding all of the dims at the begining of the page and and change the Else terms to ElseIf terms.  I'm all for efficiency.  I have to say though, it's quite  acompliment when you say it was well written coming from somebody like you who knows something about it to somebody like me who knows nothing.  :-)  Thank you for that.

I changed the your variable from 1ngPage to ingPage because when I tried to use 1ngpage, it would give me an "Expected identifier" error.  I figured an i looks like a 1 so that's why I used that.  Anyway, the page loads and everything and the "page" select menu is popuated with valid choices and everything but it still does not write "selected" to the option you choose when it takes you to that page.  Weird.  Anyway, here is the code as it exists now in case I have done anything wrong:

% @ LANGUAGE="VBScript" %>
% Option Explicit %>
!--#INCLUDE VIRTUAL="/service/asc/auth_all.asp"-->
%
Response.Expires = 0
Response.Buffer = True
Server.ScriptTimeout = 360
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1

Dim cmdDC, RecordSet, DataConnection, CommandText, i, strProduct, strPart, strSort, recPage, numPages, numRecs, pageSize, ingPage, strPartType, aProducts

DataConnection = "DRIVER=SQL Server;SERVER=MYSERVER;DATABASE=ProdService;UID=uid;PWD=passwd"
Set cmdDC = Server.CreateObject("ADODB.Connection")
cmdDC.Open DataConnection

strProduct = Request.Querystring("product")
strPart = Request.Querystring("parts")
strSort = Request.Querystring("sort")

If strSort = "" Then
strSort = "COMPONENT_ITEM_NUMBER ASC"
ElseIf strSort = "numeric asc" Then
strSort = "COMPONENT_ITEM_NUMBER ASC"
ElseIf strSort = "numeric desc" Then
strSort = "COMPONENT_ITEM_NUMBER DESC"
ElseIf strSort = "alpha asc" Then
strSort = "COMPONENT_ITEM_DESCRIPTION ASC"
ElseIf strSort = "alpha desc" Then
strSort = "COMPONENT_ITEM_DESCRIPTION DESC"
End If

If NOT (strProduct = "" AND strPart = "") AND NOT (strProduct = "error" OR strPart = "error") Then

recPage = CInt(Request.Form("page"))
If recPage=0 Then recPage=1

pageSize = CInt(Request.Form("recs"))
If pageSize = 0 Then pageSize = 10

Set RecordSet = Server.CreateObject("ADODB.RecordSet")
RecordSet.PageSize = pageSize
RecordSet.CacheSize = pageSize
RecordSet.CursorLocation = adUseClient
 
If strPart = "fru" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, COMPONENT_ITEM_LONG_DESC, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_804 WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY " & strSort & ""

ElseIf strPart = "urp" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER], [ACCY AND URP INDIRECT AMER], [SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_811 WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY " & strSort & ""

ElseIf strPart = "optional" AND NOT strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER], [SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_812 WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY " & strSort & ""

ElseIf strPart = "all" AND NOT strProduct="all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT AMER], [ACCY AND URP INDIRECT AMER], [ACCY AND URP DIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_ALL WHERE TOP_ITEM_NUMBER = '" & strProduct & "' ORDER BY " & strSort & ""

ElseIf strPart = "fru" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_804 ORDER BY " & strSort & ""

ElseIf strPart = "urp" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER], [ACCY AND URP INDIRECT AMER], [SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_811 ORDER BY " & strSort & ""

ElseIf strPart = "optional" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [ACCY AND URP DIRECT AMER], [SVC MFG LIST], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_812 ORDER BY " & strSort & ""

ElseIf strPart = "all" AND strProduct = "all" Then
CommandText = "SELECT COMPONENT_ITEM_NUMBER, COMPONENT_ITEM_DESCRIPTION, [FRU DIRECT AMER], [FRU INDIRECT AMER], [ACCY AND URP DIRECT AMER], [ACCY AND URP INDIRECT AMER], [SVC MFG LIST], [SVC RET FRUS CORE CREDIT], ASSEMBLY_ITEM_NUMBER, TOP_ITEM_NUMBER, SEG=CASE WHEN OM_CAT_SEGMENT1='FRUS (FIELD REPLACEABLE PARTS)' THEN 'YES' ELSE 'NO' END, COM=CASE WHEN ltrim(rtrim(COMPONENT_ITEM_LONG_DESC)) = '' THEN 'N/A' ELSE isnull(COMPONENT_ITEM_LONG_DESC, 'N/A') END FROM vIFC_SRV_PART_PRICE_LIST_ALL ORDER BY " & strSort & ""

End If

RecordSet.Open CommandText, cmdDC, 2, 2, 1

numPages = RecordSet.PageCount
numRecs = RecordSet.RecordCount

If recPage > numPages Then recPage = numPages
If recPage  1 Then recPage = 1

End If

aProducts = Array("product1", "product2", "product3", "product4", "product5")
%>
HTML>
HEAD>
SCRIPT LANGUAGE="JavaScript">
!--
function sortHandler(sort){
var URL = document.sort.site.options[document.sort.site.selectedIndex].value;
window.location.href = URL;
}
// -->
/SCRIPT>
/HEAD>
BODY>
table border="0" cellpadding="3" cellspacing="0" width="100%">
tr>
td>font face="arial, helvetica" size="2">b>Select Product/b>/font>/td>
td colspan="2">font face="arial, helvetica" size="2">b>Select Parts Type/b>/font>/td>
% If (strProduct = "" OR strPart = "") OR (strProduct = "error" OR strPart = "error") OR (numRecs = "" OR numRecs = 0) Then %>
td colspan="2">font face="arial, helvetica" size="2">b>Search For A Part Number/b>/font>/td>
% Else %>
td>font face="arial, helvetica" size="2">b>Sort By/b>/font>/td>
% End If %>
/tr>
tr>
form action="index.asp" method="get">
td>
select name="product">
option% If strProduct = "error" Then Response.Write " selected" End If %> value="error">small>Choose a product ->/small>/option>
option% If strProduct = "all" Then Response.Write " selected" End If %> value="all">small>All Products/small>/option>
% For i = 0 To ubound(aProducts) %>
option% If strProduct = aProducts(i) Then Response.Write " selected" End If %> value="%=aProducts(i)%>">%=aProducts(i)%>/option>
% Next %>
/select>
/td>
td valign="top">
select name="parts">
option% If strPart = "error" Then Response.Write " selected" End If %> value="error">small>Choose a parts type ->/small>/option>
option% If strPart = "all" Then Response.Write " selected" End If %> value="all">small>All Parts/small>/option>
option% If strPart = "fru" Then Response.Write " selected" End If %> value="fru">small>FRU Parts/small>/option>
option% If strPart = "urp" Then Response.Write " selected" End If %> value="urp">small>UR Parts/small>/option>
option% If strPart = "optional" Then Response.Write " selected" End If %> value="optional">small>Optional Accessories/small>/option>
/select>
/td>
td>
input type="submit" value="SUBMIT" onfocus="this.blur()">
/td>
/form>
% If (strProduct = "" OR strPart = "") OR (strProduct = "error" OR strPart = "error") OR (numRecs = "" OR numRecs = 0) Then %>
form action="results.asp" method="get">
td>
input type="text" size="10" maxlength="11" name="part" onfocus="if(this.value=='xxx-xxxx-xx')this.value='';" onblur="if(this.value=='')this.value='xxx-xxxx-xx';" value="xxx-xxxx-xx">
/td>
td>
input type="submit" value="SUBMIT" onfocus="this.blur()">
/td>
/form>
% End If %>
% If NOT (strProduct = "" OR strPart = "") AND NOT (strProduct = "error" OR strPart = "error") AND NOT (numRecs = "" OR numRecs = 0) Then
%>
form name="sort">
td>
select name="site" size=1 onchange="javascript:sortHandler()">
option% If strSort = "COMPONENT_ITEM_NUMBER ASC" Then Response.Write " selected" End If %> value="index.asp?product=%=strProduct%>&parts=%=strPart%>&sort=numeric%20asc">small>Part Number ->!--&#8593;-->/small>/option>
option% If strSort = "COMPONENT_ITEM_NUMBER DESC" Then Response.Write " selected" End If %> value="index.asp?product=%=strProduct%>&parts=%=strPart%>&sort=numeric%20desc">small>Part Number <-!--&#8595;-->/small>/option>
option% If strSort = "COMPONENT_ITEM_DESCRIPTION ASC" Then Response.Write " selected" End If %> value="index.asp?product=%=strProduct%>&parts=%=strPart%>&sort=alpha%20asc">small>Description A-Z/small>/option>
option% If strSort = "COMPONENT_ITEM_DESCRIPTION DESC" Then Response.Write " selected" End If %> value="index.asp?product=%=strProduct%>&parts=%=strPart%>&sort=alpha%20desc">small>Description Z-A/small>/option>
/select>
/td>
/form>
% End If %>
% If NOT (strProduct = "" OR strPart = "") AND NOT (strProduct = "error" OR strPart = "error") AND NOT (numRecs = "" OR numRecs = 0) Then %>
form action="download.asp" method="post">
td>
img src='/pix/spacer.gif' width='5' height='1'>
input type="image" value="PRINTER-FRIENDLY" src="/pix/printer_small.gif" width="16" height="16" border="0">
input type="hidden" name="product" value="%=strProduct%>">
input type="hidden" name="part" value="%=strPart%>">
/td>
/form>
% End If %>
/tr>
/table>
%
If strProduct = "" AND strPart = "" Then
Response.Write("p>font face='arial, helvetica' size='2'>Select a product and parts type from the select menus above and click "submit"./font>/p>")

Else If strProduct = "error" OR strPart = "error" Then
Response.Write("p>font face='arial, helvetica' size='2'>b>You must select a product and a parts type from the menus to generate a list.
You may select 'All Products' or 'All Parts' to generate a list for all products or parts./b>/font>/p>")

Else

Response.Write ("
")
Response.Flush

If strPart = "fru" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("p>font face='arial, helvetica' size='2'>b>There are no FRU parts for the " & strProduct & " at this time./b>/font>/p>")

Else If strPart = "urp" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("p>font face='arial, helvetica' size='2'>b>There are no UR parts for the " & strProduct & " at this time./b>/font>/p>")

Else If strPart = "optional" AND RecordSet.BOF AND RecordSet.EOF Then
Response.Write("p>font face='arial, helvetica' size='2'>b>There are no optional accessories for the " & strProduct & " at this time./b>/font>/p>")

Else

RecordSet.AbsolutePage = recPage

For i = 1 To pageSize
If NOT RecordSet.EOF Then

Response.Write("table border='0' cellpadding='3' cellspacing='0' width='100%'>")

If strSort = "COMPONENT_ITEM_NUMBER ASC" OR strSort = "COMPONENT_ITEM_NUMBER DESC" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Part Number/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>b>" & RecordSet.Fields("COMPONENT_ITEM_NUMBER") & "/b>/font>/td>")
Response.Write("/tr>")
Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Description/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & RecordSet.Fields("COMPONENT_ITEM_DESCRIPTION") & "/font>/td>")
Response.Write("/tr>")

Else If strSort = "COMPONENT_ITEM_DESCRIPTION ASC" OR strSort = "COMPONENT_ITEM_DESCRIPTION DESC" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Description/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & RecordSet.Fields("COMPONENT_ITEM_DESCRIPTION") & "/font>/td>")
Response.Write("/tr>")
Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Part Number/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>b>" & RecordSet.Fields("COMPONENT_ITEM_NUMBER") & "/b>/font>/td>")
Response.Write("/tr>")

End If
End If

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Returnable?/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & RecordSet.Fields("SEG") & "/font>/td>")
Response.Write("/tr>")

End If

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" AND Session("Company") = "apti" OR Session("Company") = "ahearn" OR Session("Company") = "bax" OR Session("Company") = "kodak" OR Session("Company") = "dhl/elc" OR Session("Company") = "data exchange" OR Session("Company") = "free electronica" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU DIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" AND Session("Company") = "services" OR Session("Company") = "projector doctor" OR Session("Company") = "" AND Session("IP") = "209.84.97.250" OR Session("Company") = "" AND Session("IP") = "209.84.97.254" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>FSC/ISC Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU DIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")
Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>ASC Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU INDIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("FRU INDIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" AND Session("Company") = "apti" OR Session("Company") = "ahearn" OR Session("Company") = "bax" OR Session("Company") = "kodak" OR Session("Company") = "dhl/elc" OR Session("Company") = "data exchange" OR Session("Company") = "free electronica" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP DIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" AND Session("Company") = "services" OR Session("Company") = "projector doctor" OR Session("Company") = "" AND Session("IP") = "209.84.97.250" OR Session("Company") = "" AND Session("IP") = "209.84.97.254" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>FSC/ISC Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP DIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")
Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>ASC Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP INDIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP INDIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

ElseIf Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "812" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("ACCY AND URP DIRECT AMER") & ".00/font>/td>")
Response.Write("/tr>")

End If

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>List Price/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("SVC MFG LIST") & ".00/font>/td>")
Response.Write("/tr>")

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" AND NOT RecordSet.Fields("SEG") = "NO" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Return Credit/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>$" & RecordSet.Fields("SVC RET FRUS CORE CREDIT") & ".00/font>/td>")
Response.Write("/tr>")

End If

If strPart = "all" Then

If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "804" Then
strPartType = "Field Replaceable Unit (FRU)"
Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "811" Then
strPartType = "User Replaceable (UR) Part"
Else If Mid(RecordSet.Fields("ASSEMBLY_ITEM_NUMBER"), 1, 3) = "812" Then
strPartType = "Optional Accessory"
End If
End If
End If

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Part Type/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & strPartType & "/font>/td>")
Response.Write("/tr>")

End If

If strProduct = "all" Then

Response.Write("tr>")
Response.Write("td width='20%'>font face='arial, helvetica' size='2'>b>Used On/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & RecordSet.Fields("TOP_ITEM_NUMBER") & "/font>/td>")
Response.Write("/tr>")

End If

Response.Write("tr>")
Response.Write("td width='20%' valign='top'>font face='arial, helvetica' size='2'>b>Comments/b>/font>/td>" &_
               "td>font face='arial, helvetica' size='2'>" & RecordSet.Fields("COM") & "/font>/td>")
Response.Write("/tr>")
Response.Write("/table>")

RecordSet.MoveNext

If NOT RecordSet.EOF Then

Response.Write("table border='0' cellpadding='0' cellspacing='5' width='100%'>")
Response.Write("tr>")
Response.Write("td bgcolor='#339900' height='1' colspan='2'>img src='/pix/spacer.gif' height='1'>/td>")
Response.Write("/tr>")
Response.Write("/table>")

End If

End If
Next

RecordSet.Close
Set RecordSet = Nothing

End If
End If
End If
End If
End If

If NOT numRecs = "" AND NOT numRecs = 0 Then
%>
form name="recsform" action="index.asp?%=Request.Servervariables("QUERY_STRING")%>" method="post">
p>!--font face="arial, helvetica" size="2">%=numRecs%> Records/font>
-->
font face="arial, helvetica" size="2">Show /font>
select name="recs" onchange="updateBoxes(recsform)">
% If numRecs  10 Then %>
option value="%=numRecs%>">%=numRecs%>/option>
% End If %>
% If numRecs >= 10 Then %>
option% If pageSize = 10 Then Response.Write " selected" End If %> value="10">10/option>
% End If %>
% If numRecs >= 25 Then %>
option% If pageSize = 25 Then Response.Write " selected" End If %> value="25">25/option>
% End If %>
% If numRecs >= 50 Then %>
option% If pageSize = 50 Then Response.Write " selected" End If %> value="50">50/option>
% End If %>
% If numRecs >= 100 Then %>
option% If pageSize = 100 Then Response.Write " selected" End If %> value="100">100/option>
% End If %>
% If numRecs = 100 AND NOT numRecs  10 Then %>
option% If pageSize = numRecs Then Response.Write " selected" End If %> value="%=numRecs%>">All/option>
% End If %>
/select>
font face="arial, helvetica" size="2"> records per page/font>

!--font face="arial, helvetica" size="2">Page %=recPage%> of %=numPages%>/font>
-->
font face="arial, helvetica" size="2">Display page /font>
!--select name="page">
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
option>/option>
/select>-->
select name="page">
% For ingPage = 1 To numPages %>
option% If ingPage=recPage Then Response.Write " selected" %> value="%=ingPage%>">%=ingPage%>/option>
% Next %>
/select>

input type="submit" value="GO" onfocus="this.blur()">/p>
/form>
SCRIPT LANGUAGE="JavaScript">
!--
NUM_RECORDS = %=numRecs%>;
function updateBoxes(theFormObj)
{
var selectedRecs = theFormObj.recs.options[theFormObj.recs.selectedIndex].value;
var numpages = Math.ceil(NUM_RECORDS / selectedRecs);
var numOptions = theFormObj.page.length;
for(var i=0 ; inumOptions ; i++){
theFormObj.page.options[0] = null;
}
for(var j=0 ; jnumpages ; j++){
theFormObj.page.options[j] = new Option(j+1,j+1);
}
theFormObj.page.selectedIndex = 0;
}
updateBoxes(document.recsform);
// -->
/SCRIPT>
%
End If

cmdDC.Close
Set cmdDC = Nothing
%>
p> /p>
/BODY>
/HTML>
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 51 total points
Comment Utility
Oh, I see. There is a javascript running at the creation of the page, that does much the same as the loop, only it does not set the current page. It's used when changing the page size. And also used when the page loads, but that's not needed now, as the select list is already filled.

Remove this line at the end of the script:
updateBoxes(document.recsform);

Oh, and it wasn't 1ngPage or ingPage, it was lngPage. "lng" as in "long", meaning long integer. You really should copy and paste instead of typing off the screen. ;)
0
 

Author Comment

by:beegled
Comment Utility
GreenGhost, I'm sorry, I should have caught that myself.  Thank you so much for the effort and the help.  Of course it works great now!  Thank you again.  I really do appreciate it.

giladBoker, thank you too for your effort and help.  I really appreciate that.

David
0
 

Author Comment

by:beegled
Comment Utility
BTW, you are definitely right about the typing off the screen thing.  It's a real bad habit I need to get out of.  :-)

David
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now