Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2005, 01:38 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read/Write cookies with a form text input

I have a form with a name textbox and users complete this form maybe 20+ times a day. after they enter their name once I want the value to auto-populate everytime they return to the form. I tried with the below code for cookies, but for some reason it is not working. PLEASE HELP!!!! My code is below....


<%
'set's the cookie value to textbox value
Response.cookies("name")= Request.form("name")
%>

<%
'set the expire date
Response.cookies("name").expires = date + 365
%>

'html textbox with value
<input name="name" type="text" value="<%=(Request.cookies("name"))%>">



THANKS!!!!!!
 
Old January 25th, 2005, 02:20 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Is it throwing any error?

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 25th, 2005, 02:25 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please try the following:

<%
'set's the cookie value to textbox value
if Request.form("name") <> "" then
    Response.cookies("name")= Request.form("name")
    'set the expire date
    Response.cookies("name").expires = date + 365
end if
%>

Hope this helps

Om Prakash
 
Old January 25th, 2005, 02:45 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, it is not giving an error message. I deleted all my cookies and tested the form. It will not write or read the cookie
 
Old January 25th, 2005, 02:49 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, Om Prakash that did not work either.

thanks for all your help...Any other ideas.
 
Old January 25th, 2005, 03:51 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I tried the code and it stores and displays the cookie.
I hope Cookies are enabled from where u are checking.

This is what i done:
Enter some text in text box, and submit. Close the browser and open again, and i got the cookie which was set earlier.


Om Prakash
 
Old January 25th, 2005, 04:02 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For some reason it is not happening for me. I ran a script to check if cookies are enabled and they are. And they work on my machine for other websites. Can you possibly post your code so I can compare.

thanks for all your help......

 
Old January 25th, 2005, 04:11 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

This is the code which i checked:

<form name='formaa' method='post' ID="Form1">
<br><br><input name="name" type="text" value="<%=(Request.cookies("name"))%>" ID="Text2">
<br><input type=submit>
</form>
<%
'set's the cookie value to textbox value
if Request.form("name") <> "" then
    Response.cookies("name")= Request.form("name")
    'set the expire date
    Response.cookies("name").expires = date + 365
end if
%>


Om Prakash
 
Old January 25th, 2005, 04:37 PM
Authorized User
 
Join Date: Jan 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Same as my code.

Not sure what the problem is. anybody else have any ideas?

thanks very much






Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a form with input text that is populated shawn.bordeaux Classic ASP Basics 0 November 10th, 2008 11:22 PM
Direct I/O read/write pakman VB.NET 2002/2003 Basics 1 September 13th, 2006 03:27 PM
How Can I Read or Write to Parallel Port? qdata Visual C++ 3 January 31st, 2005 07:47 AM
write info from user input into a text file pkdev Classic ASP Components 1 September 20th, 2003 01:59 PM
Display bar code in a Form using user input text? phoenixcu Access VBA 1 June 6th, 2003 02:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.