Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
11-07-2012, 10:03 PM #1
- Join Date
- Nov 2012
- Thanked 0 Times in 0 Posts
Transferring input value from a page to the previous page
Do you have an idea of how I can get the value of an html textbox input with id= keeper; I want to store its value into the cookie ‘firstname’ , so it can be used on the previous page, within the same session.
11-08-2012, 01:26 AM #2
Ummm...that is VBScript, yes, but it is ASP code. *SERVER*-side code. Not code in the browser.
And you can *NOT* use document.getElementById( ) in ASP code.
If you need the cookie value in your ASP code, then you should stick to doing it this basic way. But instead do something likewhere "keeper" is the *NAME* of a form field in the page as submitted to ASP.Code:Response.Cookies("firstname") = Trim(Request("keeper"))
However... With ASP code, you can *NOT* read the value of a cookie that was created or changed ON THE SAME PAGE.
In other words, in the code you show there, when you doyou would be getting the value of the cookie AS IT WAS WHEN THE PAGE WAS CALLED. The line above, where you set the cookie via Response.Cookies would *NOT* affect the value you get from Request.Cookies.Code:fname = Request.Cookies("firstname")
This is different than in-browser code. Which makes sense: The value of a cookie *IS* a browser-side thing. If you change it in the browser, of course you can read it back immediately. But the ASP code won't change the value in the browser until the HTML generated by the ASP page is *sent* to the browser.
What I am REALLY curious about: How can the cookie I store right this second affect what the "previous page" contained when I viewed it 10 minutes ago. Are you expecting cookies to implement some kind of time machine??
Last edited by Old Pedant; 11-08-2012 at 01:29 AM.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.