Set Session Variable and Redirect

K

Keith

I have a list of items drawn from a SQL DB and listed on an ASP page. This
works fine.

How can I make it so that when a user clicks a particular item, a session
variable is set to the ID of the item and the user redirected to another
page?

Thanks
 
K

Kris Eiben

link to the page you're on, with the id in the querystring. at the top
of the page, check for the querystring id, if <> "" then set the session
var and response.redirect to the next page.

for a bit more security, you could create a hidden form pointing to the
page you're on, set to post (so the id won't be in the querystring), and
have the link be javascript that changes the value of the id field to
that item's id and submits the form.
 
D

David C. Holley

http://www.gatewayorlando.com/content/transportationFaresGatewayRateSheet.asp

Features a list of destinations which when clicked will load a several
session variables and then redirect to a reservation request form. This
particular example uses a JavaScript function tied to the onClick event
for each TR.

onClick="trOnClick('38','20');"

function trOnClick(orgKey, destKey)
{
document.frmResortRateSheet.dropOffLocation.value = _
document.getElementById('destText' + destKey).innerHTML;

document.frmResortRateSheet.action = _
'../processingScripts/reservationRequestV3_loadTransfer.asp?org=' +
orgKey + '&dest=' + destKey;

document.frmResortRateSheet.submit();
}

The example above involves a form and changing the form's action before
submitting the form using code. An alternative would be to simply call
the page directly.

function trOnClick(destKey)
{
window.location.href='../processingScripts/rateQuoteSearch_setLocation.asp?location='
+ destKey
}

You could of course just set the onClick event to "window.location.href...".

David H
www.gatewayorlando.com
 
D

David C. Holley

The ASP page called in my examples looks something like this

<% session("variableName") = "hello world"
response.redirect ("../content/reservationRequestV3_submit.asp")%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,408
Latest member
AlenaRay88

Latest Threads

Top