Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print Form results on the same page?

Status
Not open for further replies.

slakker

MIS
Jun 5, 2003
59
0
0
US
Hi all,

I have a form of about 14 questions.. I'd like the users to be able to fill out the form, hit submit, and have the questions (premade) and answers (what they actually filled out) printed on the same page below the form.. the user will then copy questions/answers and paste somewhere else..

Is this possible?
Is it also possible to make the questions some kind of an object so i can display them below the form.. instead of retyping the questions as well?

Thanks
 
I found this code, maybe someone can show me how to add a questions to that field.. like NAME:, make it a variable that I can pass down to printed answers..
 
<!--form entry-->
<form method="post" action="<%=script_name%>">
<input type="text" name="Name">
<input type="submit" name="submit">
</form>

<%
'dim the variables
Dim strName,strLname,intNameLength,intWhere,intEndName
Name=Request.form("Name")

'check to see if anything was submitted
if Name="" then
response.write" nothing submitted"
else

Name=Fix(Name) 'run fix function
NameLength=Len(Name) ' find length of text submitted
Where=InStr(Name,"*") 'find where in string * resides
EndName=Namelength-where 'find out how many letters are left after the *
Lname=right(Name,EndName) ' Trim the text after the *

response.write Lname ' print out result

end if

'this to find spaces and replace with *
Function FIX(NAME)
FIX=replace(Name," ", "*")
end Function
%>
 
Response.Write and Request.Form are the main things you need. formatting it is secondary and trivial.

after the form is submitted you simply write the form collection out.

e.g
response.write request.form("Name")

not much more to it. really! :)

you can also make the questions session variables to keep their state or value. kind of a half a** constant.

e.g.
question one
session("question_1") = "why do I keep trying"

then you can just do a

response.write session("question_1")
response.write "<br> your answer was : " & request.form("answer_1")



___________________________________________________________________
[sub]
onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811
[/sub]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top