Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submiting a form with a hyperlink

Status
Not open for further replies.

blueindian1

Programmer
Apr 24, 2001
150
US
Hello,

I hoping someone can tell me a good way to submit a form with a hyperlink in ASP. Let me give you the problem:

1. An advanced search box has been filled out by a user in order to limit the results they get back

2. The recordset returns 100 results, paged out 10 at a time

3. When the user clicks the "next" hyperlink to go to the second page of results, the query is resubmitted and the second page of results is pulled out.

4. The problem is that I need to submit the advanced search form again, such that the search params to limit the query are again available.

Basically, what I need to do is submit the search form again with the page number attached to it.

(if this design were up to me, I'd put the search parms in a session variable to begin with...so this would not be an issue. however...i'm just a grunt so I don't get to design :) )

Thanks!

 
instead of resubmitting the form save the results in a temp file, and use the file to retrieve the data. it's much faster and will prevent the overhead of calling the database everytime. use the session id to make sure you create a unique filename and use the Session_OnEnd in your global.asa file to delete the file when the session has ended.
if you need an example let me know :) (-:
 
stakadush..

i would love an example of that for my own personal use. however, for this project i have to go along with someone else's design...my hands are tied. this is the way they want it done, so it is the way i'll have to do it.

thanks
 
Blue Indian,

Which way is that ?? So far I've seen two good solutions here, one of which was your idea. So which way do they want you to do it ??

ToddWW
 
I can't do it either way. My way(using session variables) and stakadush's way (using a file) were both declined by the folks in charge of designing this page.

So, I'm looking for a way to submit a form via a "next page" hyperlink while at the same time passing the page number that I want.

What would work is if when I clicked "next page" i could pull the page number and set that value in a hidden field on the form before it was submitted. I'm trying to do this with a bit of JavaScript, but no luck so far.
 
then all you have to do is something like this:
[cdoe]
Dim strURL
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
For Each strRequest In Request.Form
strRequest = Server.URLencode(strRequest)
strURL = strURL & strRequest &"="& Request.Form(strRequest) &"&"
Next
Else
For Each strRequest In Request.QueryString
strRequest = Server.URLencode(strRequest)
strURL = strURL & strRequest &"="& Request.QueryString(strRequest) &"&"
Next
End If

'remove the last &
strURL = Left(strURL,Len(strURL)-1)

strURL = " strURL
[/code]

something like this should do it. using the loop you get all the variables from the search form, encode it, and add it to strURL. you then use strURL as your link. you can add something like &page=2 so you know what page you're going to display.
i didn't check the code but it should work.
hope this helps. (-:
 
To answer your specific question..
Code:
<input type=&quot;hidden&quot; name=&quot;next&quot; value=&quot;<%objRS.AbsolutePage + 1%>&quot;>
<input type=&quot;hidden&quot; name=&quot;prev&quot; value=&quot;<%objRS.AbsolutePage - 1%>&quot;>

That will send the next page # and the prev page number in two seperate hidden fields to the form.

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top