View previous topic :: View next topic |
Author |
Message |
Webwench
Joined: 28 Feb 2006 Posts: 3
|
Posted: Tue Feb 28, 2006 10:28 am Post subject: Use Form input to set a session var |
|
|
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 |
|
|
Don
Joined: 22 Oct 2004 Posts: 28
|
Posted: Tue Feb 28, 2006 11:32 am Post subject: |
|
|
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 |
|
|
Webwench
Joined: 28 Feb 2006 Posts: 3
|
Posted: Tue Feb 28, 2006 2:27 pm Post subject: |
|
|
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 |
|
|
paul
Joined: 11 Oct 2004 Posts: 128
|
Posted: Tue Feb 28, 2006 2:36 pm Post subject: |
|
|
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 |
|
|
Webwench
Joined: 28 Feb 2006 Posts: 3
|
Posted: Tue Feb 28, 2006 2:46 pm Post subject: |
|
|
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. _________________ Webwench |
|
Back to top |
|
|
paul
Joined: 11 Oct 2004 Posts: 128
|
Posted: Tue Feb 28, 2006 2:58 pm Post subject: |
|
|
You're very welcome
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 |
|
|
|