ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Use Form input to set a session var

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming
View previous topic :: View next topic  
Author Message
Webwench



Joined: 28 Feb 2006
Posts: 3

PostPosted: Tue Feb 28, 2006 10:28 am    Post subject: Use Form input to set a session var Reply with quote

I'm trying to push an input value from a form into a session var. I'm thinking I need either the "on click" or "on change" in the Form to call an ASP function?? I've only done this with javascript and I seem to be missing something. I need some advice, or an example on how to do this. Or maybe there's a better way?
_________________
Webwench
Back to top
View user's profile Send private message
Don



Joined: 22 Oct 2004
Posts: 28

PostPosted: Tue Feb 28, 2006 11:32 am    Post subject: Reply with quote

onClick and onChange are javascript client-side event handlers. You cannot assign a value to Session variable (Sessions are server side) by using client-side JavaScript.

Here is how is done:

Code:


<%

If Request.Form("FirstName") <> "" Then

    Session("FirstName") = Request.Form("FirstName")

End If

%>

<form method="POST">
<input type="text" name="FirstName">
<input type="Submit" Value="Submit">
</form>




Don
Back to top
View user's profile Send private message
Webwench



Joined: 28 Feb 2006
Posts: 3

PostPosted: Tue Feb 28, 2006 2:27 pm    Post subject: Reply with quote

Sorry, I should give more info...
With this form, the onsubmit refers to a javascipt and it returns false. I was thinking that since the submit request was never set, I wouldn't be able to access it via request.form? Or maybe that not right?

The onsubmit javascript automatically generates a dynamic call to initiate a third-party compiled program; which processes the values and controls the page refresh. After the refresh, the request.form object has no values. Either they aren't getting set, or they are being wiped out by the third-party code (security). <%Request.Form("ff2300").count%> produces 0.

I think my only hope is to capture it prior to the onsubmit. I can save it to a javascript variable. I was thinking that ASP could access a javascript global variable, but I'm not having any success. Will the javascript var last for the session, or do I lose it when the page refreshes?
_________________
Webwench
Back to top
View user's profile Send private message
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Tue Feb 28, 2006 2:36 pm    Post subject: Reply with quote

Webwench wrote:
Sorry, I should give more info...
With this form, the onsubmit refers to a javascipt and it returns false. I was thinking that since the submit request was never set, I wouldn't be able to access it via request.form? Or maybe that not right?


If the form is not submitted then there will be no server side processing at all and no Session vars either.

Quote:

The onsubmit javascript automatically generates a dynamic call to initiate a third-party compiled program; which processes the values and controls the page refresh. After the refresh, the request.form object has no values. Either they aren't getting set, or they are being wiped out by the third-party code (security). <%Request.Form("ff2300").count%> produces 0.


Isn't there a way to pass some variables to the third-party program, to be passed to the page when it refreshes?

Quote:

I think my only hope is to capture it prior to the onsubmit. I can save it to a javascript variable. I was thinking that ASP could access a javascript global variable, but I'm not having any success. Will the javascript var last for the session, or do I lose it when the page refreshes?


ASP cannot access client JavaScript variables and the javascript vars are reset when the page refreshes.



Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Webwench



Joined: 28 Feb 2006
Posts: 3

PostPosted: Tue Feb 28, 2006 2:46 pm    Post subject: Reply with quote

Sadly, there is no way to get the third-party program to pass the values to the page when it refreshes. It was built that way on purpose, (security that we don't need).

Thanks much for your advice, it will save me a lot of time and frustration by not trying to do the impossible. Wink
_________________
Webwench
Back to top
View user's profile Send private message
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Tue Feb 28, 2006 2:58 pm    Post subject: Reply with quote

You're very welcome Smile

Sometimes it might be very annoying to deal with third-party application, but that's the way it is.



Good luck!

Paul
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> ASP programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial