Click to See Complete Forum and Search --> : Passing variables


achat
04-30-2003, 08:51 AM
i have an asp which accepts a variable from a hyperlink. This asp has a from where i accept certain inputs and then calls another asp for further processing. I need to pass the variable that was received also into the second asp. how do i do it.

If the value of the variable was "xyz" then i am able to do it like this, but i am unable to use the variable name to dynamically pass this variable.

<FORM ACTION="engine.asp?type="xyz' NAME="form1"

METHOD="post">
User Name: <INPUT TYPE="text" SIZE=10 NAME="username">
Password: <INPUT TYPE="password" SIZE=10 NAME="password">
<INPUT TYPE="submit" VALUE="Login">
</FORM>

DaiWelsh
04-30-2003, 08:57 AM
The easiest way is using hidden fields e.g. (syntax not checked or tested)


<FORM ACTION="engine.asp" NAME="form1"
METHOD="post">

<input type="hidden" name="type" value="<%=Request.Form("type")%>">

User Name: <INPUT TYPE="text" SIZE=10 NAME="username">
Password: <INPUT TYPE="password" SIZE=10 NAME="password">
<INPUT TYPE="submit" VALUE="Login">
</FORM>

assuming that the field you passed from the previous from was called type.

HTH,

Dai

Gary
05-01-2003, 10:26 AM
i use sessions..

So if you store your variable in a session you can call it any time you want.

BillB
05-02-2003, 02:42 PM
The only problem with session variables is that they can tend to eat up server resources(especially on high volume apps) and session variables don't normally expire when a user's session expires. The server default is 20 minutes after the user's session ends.

I've always tried to stay away from session variables - they're easy, but there's no such thing as a free lunch, and there are drawbacks.

Bill

Gary
05-06-2003, 03:36 AM
can you set the expire time on the session variables?

cmelnick
05-06-2003, 02:57 PM
Not individual Session variables, just the whole Session. The Session timeout counts down from the last time a user was active on your page.

ChrisBrown
05-06-2003, 05:05 PM
Another option that you can use if you are doing a multi-screen/stepped survey that has a lot of values is to write all of the information to a cookie on the person's hard drive. That way, if they leave for some reason they can start where they left off.

Also, storing the information in a cookie until final submission saves you having to do endless hidden fields for carrying over information.

cmelnick
05-07-2003, 08:03 AM
Cookies are absolutely a great way to store data from a multi-page form. However, depending on the need of your site and the people who are going to be visiting it, you cannot depend on cookie availability. When I design a site for a wide audience, I try to incorporate various levels of browser features that will enable someone to view the page with straight html, no Javascript or Cookies, to someone with a full blown feature rich browser.

Of course there are also instances where making a blanket statement "This page will not work without cookies and Javascript" makes sense. You just have to decide the applicability for your own site.