navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Write cookie to text box?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Write cookie to text box?
Page: [1]
 
AllenD

 

Posts: 258
From: Dayton, OH, USA
Status: offline

 
Write cookie to text box? - 6/28/2001 17:19:00   
Hello All,
I am using the below code from codeave.com to record a cookie. But when the cookie is read and written back, it is just plain text. I need the cookie to write to a text box...Anyone know how I can do this from the code below?

<% response.buffer=true
' response.buffer=true is used to because there is a mix
' of html output and response.cookies when the cookie is written
%>
<html>
<title>CodeAve.com(Cookie Read & Write)</title>
<body bgcolor="#FFFFFF">
<%
u_input=request.cookies ("testcookie")("u_input")
'checks for the variable u_input from a cookie named testcookie on
' the local pc.


' If the cookie does not exist or have a value for the variable
' then check to see if the user is inputting one
if trim(u_input) = "" then
u_input=trim(request.form("u_input"))

' If the user hase enetered a value to put to the cookie write it out
if u_input <> "" then

' Write the user input to the cookie
response.cookies ("testcookie")("u_input") = u_input


' Write the expiration date (today + 3 days) to the cookie
response.cookies ("testcookie").expires = DATE + 3

' Read the cookie and write the value of u_input to the browser
response.write (request.cookies ("testcookie")("u_input")) %>
<p>
You text has been written to the cookie.<br>
Click <a href="<%= request.servervariables("script_name") %>" target="_blank">here</a>
to open this page in a new window.
<% else
' If there was no cookie info and there was no value being inputted
' then display the textbox for user input %>

<form action="<%= request.servervariables("script_name") %>" method="post">
<input type=text name=u_input> <input type=submit value=Submit>
</form>
<% end if ' end check for user inputted value
else ' if the cookie has a value
' read the cookie and write the value of u_input to the browser
response.write (request.cookies ("testcookie")("u_input"))
end if ' end check for cookie value %>

</body>
</html>

Mojo

 

Posts: 2429
From: Chicago
Status: offline

 
RE: Write cookie to text box? - 6/29/2001 20:10:00   
According to your post you wanted the cookie brought into a text box based upon your code. I tossed in a couple of forms to "catch" the cookie results. They post to a made up page. You can change it to whatever you like. I left everything else alone.

Also, a cookie will always return just plain text.

Joe

code:

<% response.buffer=true
' response.buffer=true is used to because there is a mix
' of html output and response.cookies when the cookie is written
%>
<html>
<title>CodeAve.com(Cookie Read & Write)</title>
<body bgcolor="#FFFFFF">
<%
u_input=request.cookies ("testcookie")("u_input")
'checks for the variable u_input from a cookie named testcookie on
' the local pc.


' If the cookie does not exist or have a value for the variable
' then check to see if the user is inputting one
if trim(u_input) = "" then
u_input=trim(request.form("u_input"))

' If the user hase enetered a value to put to the cookie write it out
if u_input <> "" then

' Write the user input to the cookie
response.cookies ("testcookie")("u_input") = u_input


' Write the expiration date (today + 3 days) to the cookie
response.cookies ("testcookie").expires = DATE + 3
' Read the cookie and write the value of u_input to the browser
%>
<form method="POST" action="your_page.asp">
<p><input type="text" name="T1" size="20" value="<%=response.write (request.cookies ("testcookie")("u_input"))%>"><input type="submit" value="Submit" name="B1"></p>
</form>

<p>
You text has been written to the cookie.<br>
Click <a href="<%= request.servervariables("script_name") %>" target="_blank">here</a>
to open this page in a new window.
<% else
' If there was no cookie info and there was no value being inputted
' then display the textbox for user input %>

<form action="<%= request.servervariables("script_name") %>" method="post">
<input type=text name=u_input> <input type=submit value=Submit>
</form>
<% end if ' end check for user inputted value
else ' if the cookie has a value
' read the cookie and write the value of u_input to the browser
%>
<form method="POST" action="your_page.asp">
<p><input type="text" name="T1" size="20" value="<%=response.write (request.cookies ("testcookie")("u_input"))%>"><input type="submit" value="Submit" name="B1"></p>
</form>
<% end if ' end check for cookie value %>
</body>
</html>



(in reply to AllenD)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Write cookie to text box?
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts