Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Items per Page
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

TastyNutz
Junior Member

USA
251 Posts

Posted - 24 November 2007 :  20:55:14  Show Profile  Visit TastyNutz's Homepage
I'd like to let users select the number of items displayed on each page of a product catalog. I have it working via a dropdown list, but when you navigate to the next page, the dropdownvalue is lost.

See here:
http://eshop.shnforums.com/default.asp?catid=7

Any suggestions on how to change this to make it work properly?

Attached file:
default.txt

The relevant code starts around line 109 with
' pagesize is used to set the number of records that will be
' displayed on each page.


PowerQuad Disability Support Forum

cripto9t
Average Member

USA
881 Posts

Posted - 25 November 2007 :  09:52:23  Show Profile
You need to either add it to the querystring or drop a cookie.
Something like this
dim defaultvalue, tmpValue1, tmpValue2, dropdownvalue, iperpage

defaultvalue = 3
iperpage = "&iperpage="

If Trim(Request.form("dropdownlist")) <> "" Then
	tmpValue1 = cLng(Request.Form("dropdownlist"))        'Retrieve selected value from dropdownlist
else
        tmpValue1 = ""
End if

If Trim(Request.Querystring("items")) <> "" Then
	tmpValue2 = cLng(Request.QueryString("items"))        'Retrieve selected value from querystring
else
        tmpValue2 = ""
End if

if tmpValue1 = "" then
        if tmpValue2 = "" then
                dropdownvalue = defaultvalue
        else
                dropdownvalue = tmpValue2 
        end if
else
        dropdownvalue = tmpValue1
end if

iperpage = iperpage & dropdownvalue

rs.PageSize = dropdownvalue

The select isn't working right either
<form name="dropdown" action="default.asp?cid=<%=request.QueryString("cid")%>" method="post">
    <input type = "hidden" name="selectedvalue" value="<%=dropdownvalue%>">
    <font color="#000000">Products per Page: </font>    
    <select name="dropdownlist">
        <option <%=chkSelect(dropdownvalue,3)%> value="3">3</option>
	<option <%=chkSelect(dropdownvalue,5)%> value="5">5</option>
	<option <%=chkSelect(dropdownvalue,10)%> value="10">10</option>
	<option <%=chkSelect(dropdownvalue,15)%> value="15">15</option>
	</select>  
    <input type="submit" name="Submit" value="Go">
</form>

function chkSelect(select,value)
        if select = value then
                tmpSelect = "selected"
        else
                tmpSelect = ""
        end if
        
        chkSelect = tempselect
end function

Add to querystrings in your NavBlock function
response.write ("<a href=""default.asp?cid=" & request.QueryString("cid")& iperpage & "&PageNo=" & Prev5 & """>


    _-/Cripto9t\-_
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 25 November 2007 :  19:09:38  Show Profile  Visit TastyNutz's Homepage
cripto9t, thanks, but this still needs work:

http://eshop.shnforums.com/default.asp?cid=7

One issue is below:

	If Trim(Request.Querystring("items")) <> "" Then


I don't see where "items" is found.


And the select still isn't working. I got an error with your function code, so I changed the part in red, but still no luck.


	function chkSelect(dropdownlist,value)
			if dropdownlist = value then
					tmpSelect = "selected"
			else
					tmpSelect = ""
			end if
			
			chkSelect = tempselect
	end function


Attached file:
default.txt

Any more help would be appreciated.


PowerQuad Disability Support Forum
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 26 November 2007 :  07:57:34  Show Profile
mispelling
chkSelect = tempselect
should be
chkSelect = tmpSelect

and a name change error (#*it happens )
If Trim(Request.Querystring("items")) <> "" Then
	tmpValue2 = cLng(Request.QueryString("items"))
should be
If Trim(Request.Querystring("iperpage")) <> "" Then
	tmpValue2 = cLng(Request.QueryString("iperpage"))
I'd change "dropdownlist" back. It might confuse.
I threw this together trying to adapt some code I had to yours. I don't see anymore mistakes, but that don't mean there aren't any . The main thing is to make sure it shows up in the url with the correct number.

    _-/Cripto9t\-_
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 26 November 2007 :  09:42:31  Show Profile  Visit TastyNutz's Homepage
Duh... I missed the spelling error too.

It works perfectly now. Thanks for the help!


PowerQuad Disability Support Forum
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 26 November 2007 :  11:02:53  Show Profile
You're welcome

    _-/Cripto9t\-_
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07