PDA

View Full Version : Posting to page


scriptkeeper
07-21-2003, 07:17 PM
I am just starting to learn ASP and Im playing with this

<html>
<head>
</head>
<body>
<%
postedvalue=Request("nameoffield")
%>
<form name="formname" action="test.asp" method="post">
<input type="text" name="nameoffield">
<input type="submit" value="Post">
</form>
<%
Response.Write(postedvalue)
%>

</body>
</html>


and I was wondering if there is a way to make it append what is posted each time on a new line without overwriting it. Kinda like innerHTML! I know how to do it with JS but im stuck here is it the same?

whammy
07-21-2003, 07:23 PM
Usually you'd WANT to overwrite it... but

postedvalue= postedvalue & Request("nameoffield") & "<br />"

Is that what you're trying for? ;)

oracleguy
07-21-2003, 07:24 PM
<html>
<head>
</head>
<body>
<%
postedvalue=Request.Form("past") & "<br>" & Request.Form("nameoffield")
%>
<form name="formname" action="test.asp" method="post">
<input type="text" name="nameoffield">
<input type="hidden" name="past" value="<%=postedvalue%>">
<input type="submit" value="Post">
</form>
<%
Response.Write(postedvalue)
%>

</body>
</html>

That should do it.

whammy
07-21-2003, 07:26 PM
P.S. If you just want to get all of the values, you can do:

For Each Item in Request.Form
Response.Write(Item & ": " & Request.Form(Item) & "<br />" & vbCrLf)
Next

Not tested, hope I didn't have a typo

scriptkeeper
07-21-2003, 07:46 PM
That Hit the spot oracleguy thanx! But the post will not stay the same will it upon refresh or another user coming to page. So how would I make them stay so that everyone veiwing the page sees them. I sure this is done with a database just dont know how?

whammy
07-21-2003, 07:49 PM
Well, you've gotta store them in a database.

I'd take some tutorials, such as at:

http://www.w3schools.com/asp

And also look at some example scripts, you can find them all over the place...

http://www.4guysfromrolla.com
http://www.haneng.com

are a couple of other good ones.