How do I store value in textarea with session (or any).

Hello, experts
I would like to store whatever user types in text area as session value (or cookie or any)
Could somebody show me how do I do it?

<%

session("tempnotes") = "mytext"

<textarea id= 'mytext' >
Response.Write(Session("tempnotes"))
</texarea>

%>
????


Thanks

jtuttle99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hc0904pcdCommented:
session("tempnotes") = request.form("mytext")
0
hc0904pcdCommented:
ps in your snippet of code, you have </texarea> - I think you mean to have </textarea> here instead?
0
jtuttle99Author Commented:
Thank you for your help.
I could save the value, but I get same value in this dynamic page.
Item.asp page is a dynamic page and the contents changes based on itemID.

So, item.asp?itemID=001 and item.asp?itemID=002 has different pic and information.
However, the text area has same value.
How do I save EACH text area value based on itemID?
Is this something I can't do with session?
Here is the code i've got so far.


Item.asp-------

<form action="savenote.asp" method=post>
<textarea name='mytext' id='mytext' cols=65 rows=3>
<%  Dim tempnotes
      tempnotes = session("tempnotes")
%>
<%=response.write(session("tempnotes"))%>
</textarea>
<input type="image" src="save.gif">
</form>


savenote.asp---

<%
session("tempnotes") = request.form("mytext")
response.redirect Request.ServerVariables("HTTP_REFERER")
%>
0
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

hc0904pcdCommented:
Hi,
Just to clarify.

item.asp is your form page, which writes to savenote.asp.

In item.asp, on arrival you are pre-populating the field mytext with whatever the person last wrote here, in their current browser session.
They then either hit submit, or they change that value and then hit submit.

In the next page, savenote.asp, you take whatever they wrote, and put it in a session called "tempnotes"
At that stage you could put
response.write session("tempnotes")
response.end
if you want to check what value is in that session at this stage.

After that, it looks like you're redirecting the user somewhere - where? What is the next page after savenote.asp? And do they need to have the value of session("tempnotes") on that next page?


0
jtuttle99Author Commented:
Yes, item.asp is my form page which sends text area value to savenote.asp when they hit save button.
savenotes.asp creates session value called "tempnote" and redirect to where you were in item.asp.
Just going back to item.asp?itemID=********
(that's because item.asp changes contents depend on itemID. so
If I was in item.asp?itemID=001, I would like to go back item.asp?itemID=001.)
Then, session value in the text will be in text area in item.asp.

I couldn't come up with other way, so any suggestion will be helpful.
I would like to save different text value for each page (item.asp?itemID=001,item.asp?itemID=002,item.asp?itemID=003)

I attached code snippet. Please save it as item.asp and it will explain better.
I will attach one more snippet on next comment.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #CC0000}
.style2 {color: #990066}
.style3 {color: #993399}
-->
</style>
</head>
 
<body>
<form action="savenote.asp" method=post>
<textarea name='mytext' id='mytext' cols=65 rows=3>
<%  Dim tempnotes
   tempnotes = session("tempnotes")
%>
<%=response.write(session("tempnotes"))%>
</textarea>
<input type="image" src="save.gif">
</form>
<%dim itemID 
itemID=request.QueryString("itemID")%>
<% if itemID=001 then %><p class="style1"> this is item1 content</p>
<p>view <a href="item.asp?itemID=002">item2</a>, <a href="item.asp?itemID=003">item3 </a></p>
<%elseif  itemID=002 then %> <p class="style2"> this is item2 content</p>
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=003">item3 </a></p>
<%elseif  itemID=003 then %> <p class="style3"> this is item3 content</p>
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=002">item2 </a></p>
<%else%> 
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=002">item2,<a href="item.asp?itemID=002">item3 </a></p>
<%end if %>
<p><a href="clearnote.asp">clear</a>
</p>
</body>
</html>

Open in new window

0
jtuttle99Author Commented:
Please save this as "savenote.asp"
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<%
session("tempnotes") = request.form("mytext")
response.redirect Request.ServerVariables("HTTP_REFERER")
%>

Open in new window

0
hc0904pcdCommented:
hi,
sorry for the delay in getting back to you.

in savenote.asp, if you comment out the line  
' session("tempnotes") = request.form("mytext")

and add in these 3 lines       

for each object in request.form                  
  session(object) = request.form(object)
next

then you will have as session variables, each item from the form.
for example if you have in the an item called itemID003, then you can reference that after submission by calling session("itemID003")

hope this helps?

0
jtuttle99Author Commented:
Thank you for your help!
This is a basic question, but I don't know what goes where...

So, in this case I replace object with ???

for each ?????? in request.form                  
  session("tempnotes") = request.form("mytext")
next


then, do I have to replace in item.asp?
<textarea name='mytext' id='mytext' cols=65 rows=3>
<%  Dim tempnotes
   tempnotes = session("tempnotes")
%>
<%=response.write(session("tempnotes"))%>
</textarea>
0
hc0904pcdCommented:
hi,
in the first bit you don't need to change anything.

for each object in request.form                  
  session(object) = request.form(object)
next

this will get everything from the form and place it in a session.
for example if your form has an input field called "telephone_number", then after submission you will have a session variable called "telephone_number".


in item.asp, replace

<textarea name='mytext' id='mytext' cols=65 rows=3>
<%  Dim tempnotes
   tempnotes = session("tempnotes")
%>
<%=response.write(session("tempnotes"))%>
</textarea>

with this code

<textarea name='mytext' id='mytext' cols=65 rows=3>
<% if session("mytext") <> "" then response.write(session("mytext"))%>
</textarea>

and do the same for every other input field, making sure that where I've put "mytext" you change it to be the same as the form field name.

0
jtuttle99Author Commented:
Sorry, it's still giving me same value when I hit "view item * " button.
Am I missing something?

Here is the code for savenote.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<%
' session("tempnotes") = request.form("mytext")
for each object in request.form                  
  session(object) = request.form(object)
next
response.redirect Request.ServerVariables("HTTP_REFERER")
%>

Open in new window

0
jtuttle99Author Commented:
And item.asp

Thank you for your help.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #CC0000}
.style2 {color: #990066}
.style3 {color: #993399}
-->
</style>
</head>
 
<body>
<form action="savenote.asp" method="post">
<textarea name='mytext' id='mytext' cols=65 rows=3>
<% if session("mytext") <> "" then response.write(session("mytext"))%>
</textarea>
<input type="image" src="save.gif">
</form>
<%dim itemID 
itemID=request.QueryString("itemID")%>
<% if itemID=001 then %><p class="style1"> this is item1 content</p>
<p>view <a href="item.asp?itemID=002">item2</a>, <a href="item.asp?itemID=003">item3 </a></p>
<%elseif  itemID=002 then %> <p class="style2"> this is item2 content</p>
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=003">item3 </a></p>
<%elseif  itemID=003 then %> <p class="style3"> this is item3 content</p>
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=002">item2 </a></p>
<%else%> 
<p>view <a href="item.asp?itemID=001">item1</a>, <a href="item.asp?itemID=002">item2,<a href="item.asp?itemID=003">item3 </a></p>
<%end if %>
<p><a href="clearnote.asp">clear</a>
</p>
</body>
</html>

Open in new window

0
jtuttle99Author Commented:
I wasn't sure what I'm supposed to change so the code doesn't include your answer.

""and do the same for every other input field, making sure that where I've put "mytext" you change it to be the same as the form field name.""


Did you mean like this??
<input type="image" src="save.gif" name='mytext' id='mytext'>
0
hc0904pcdCommented:

<input type="image" src="save.gif" name='name_of_this_item' id='name_of_this_item' value='<% if session("name_of_this_item") <> "" then response.write(session("name_of_this_item"))%>'>
0
hc0904pcdCommented:
for each field in the form, "name_of_this_item" should be unique
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jtuttle99Author Commented:
Thank you so much all your help!!
It works now.
0
hc0904pcdCommented:
glad i could help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.