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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing values

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi

I have inherited an ASP page, which when the user clicks proceed, the second page runs this (i.e passes the values from the first page as hidden)

<%
Function IncludeHidden()
For each Field in Request.Form
TheString=&quot;<input type=&quot;&quot;HIDDEN&quot;&quot; name=&quot;&quot;&quot; & Field & &quot;&quot;&quot; value=&quot;&quot;&quot;
StrValue = Request.Form(Field)
TheString=TheString + cstr(StrValue) & &quot;&quot;&quot;>&quot; & VbCrLf
Response.Write TheString
Next
End Function
%>

There is a third page which does the same - then the user is taken to a submit.asp page which does this (inserts the values into a Databases)

<%
Dim myConn
Dim SQLString

Set myConn = Server.CreateObject(&quot;ADODB.Connection&quot;)

connStr = &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & server.mappath(&quot;HsgPlanApp.mdb&quot;)
myConn.Open connStr,&quot;&quot;,&quot;&quot;

SQLString = &quot;INSERT INTO tblHsgPlanApp (&quot;

For each Field in Request.Form
SQLString = SQLString & Field & &quot;, &quot;
Next

SQLString = Left(SQLString, (Len(SQLString) -2))

SQLString = SQLString + &quot;) VALUES (&quot;

For each Field in Request.Form
StrValue = Request.Form(Field)
SQLString = SQLString + &quot;'&quot; & Request(Field) & &quot;', &quot;
Next

SQLString = Left(SQLString, (Len(SQLString) -2))
SQLString = SQLString + &quot;);&quot;
response.write SQLString
myConn.Execute(SQLString)

On the Submit.asp page I have a link to PrintPage.asp called by this.

<script language=&quot;JavaScript&quot;>
<!--
function open_new_window(url)
{
new_window = window.open(url,'window_name','toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width=400,height=300,left=25,top=25')
}
</script>
<a href=&quot;javascript:eek:pen_new_window(' Form</a>

I want this PrintPage.asp to display all the values in basic text format (i.e. a label and a value) - I know I can't use request.form, because submit.asp doesn't have any form tags

Any help much appreciated
Richey
I just want PrintPage.asp
 
Well, I suppose you could output the data in submit.asp as hidden fields...so they'd be available to printpage.asp.

<input type=hidden name=h_name value=&quot;myvalue&quot;>

Otherwise, you should be able to pass the data as url variables at the end of your url string, like:

printpage.asp?p-var1=thisvalue&p-var2=myvalue

If you use the URL method, make sure to URL encode the values, so any spaces & other restricted characters are &quot;made safe&quot; to be passed in a URL. Not sure how to do that off the top of my head...

Good luck!
Jessica
 
I'd like to use the hidden fields method, but how?

I've tried, putting in submit.asp

<input type=&quot;text&quot; name=&quot;Section1_Surname&quot; value=<%request.form(&quot;Section1_Surname&quot;)%>>

I've used text instead of hidden to test it

but the field is blank when I run the page (there definitely is a value in Section1_Surname)
do I need <form> tags?

 
It may be easier to do it in javascript when you open the url. You will need them in a form.

Try this:
.

<script language=&quot;JavaScript&quot;>
<!--
function open_new_window(url)
{
params = &quot;?p-var1=&quot; + escape(document.forms[0].Section1_Surname.value);
newpage = url + params;
new_window = window.open(url,'window_name','toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width=400,height=300,left=25,top=25')
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top