Using cookies to save parameters

C

ConnerS

According to my Frontpage 2002 Developers guide, I can use cookies to save a
parameter to be used in ASP pages. The guide is just vague enough that I
have not been able to figure out how to make it work.
The way I have it now (see this page:
http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the search), User can write "Description"
"ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
database if they have a NameID and LName that match. Originally, I had the
confirmation page with a link back to the Add.asp page, but the parameter for
NameID was lost once form was submitted to the database.
Once they have entered the information, I want the user to be able to add
additional events, without returning to the search page to get the parameter
for NameID.
The cookie should expire at the end of the session.

Where would I find the syntax, or is it simple enough that someone could
just give me the syntax, what page does it go in, and where in the page
should it go?

I appreciate any help, or any direction.
 
S

Stefan B Rusynko

See http://www.w3schools.com/asp/asp_cookies.asp

But I would recommend not using cookies
Instead use Session variables

Create the Session variable using you form field as
Session("NameID") = Request.Form("NameID")

Call it using
NameID = Session("NameID")
or in a new form field value using
<%=Session("NameID")%>

See http://www.w3schools.com/asp/asp_sessions.asp




| According to my Frontpage 2002 Developers guide, I can use cookies to save a
| parameter to be used in ASP pages. The guide is just vague enough that I
| have not been able to figure out how to make it work.
| The way I have it now (see this page:
| http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the search), User
can write "Description"
| "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| database if they have a NameID and LName that match. Originally, I had the
| confirmation page with a link back to the Add.asp page, but the parameter for
| NameID was lost once form was submitted to the database.
| Once they have entered the information, I want the user to be able to add
| additional events, without returning to the search page to get the parameter
| for NameID.
| The cookie should expire at the end of the session.
|
| Where would I find the syntax, or is it simple enough that someone could
| just give me the syntax, what page does it go in, and where in the page
| should it go?
|
| I appreciate any help, or any direction.
 
C

ConnerS

I see where the session variable is more what I want, thanks for the two
links. What page and where on the page do I put the . (After the query on
Search.asp is where the NameID is established)
Session("NameID") = Request.Form("NameID")
I put the <%=Session("NameID")%>
as the hidden field in the form of AddMore.asp. the form works and writes
the 3 text boxes, but not the NameID.
 
S

Stefan B Rusynko

Your form at
http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
Has an ACTION="Search.asp"
- meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form

So in order to get a value for NameID the form needs to be sent at least once

Then anywhere in the receiving page check for the form field value and get it its value if it is not empty

<%
If NOT IsEmpty(Request.Form("NameID"))
Session("NameID") = Request.Form("NameID")
End if
%>

Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden field -
such as in the page AddMore.asp using

<input type="hidden" name="NameID" value="<%=Session("NameID")%>">


PS
You add VBScript by delimiting it as a script
- not by just entering it in a page as you apparently have after your </body> tag on Search.asp




|I see where the session variable is more what I want, thanks for the two
| links. What page and where on the page do I put the . (After the query on
| Search.asp is where the NameID is established)
| Session("NameID") = Request.Form("NameID")
| I put the <%=Session("NameID")%>
| as the hidden field in the form of AddMore.asp. the form works and writes
| the 3 text boxes, but not the NameID.
|
|
| "Stefan B Rusynko" wrote:
|
| > See http://www.w3schools.com/asp/asp_cookies.asp
| >
| > But I would recommend not using cookies
| > Instead use Session variables
| >
| > Create the Session variable using you form field as
| > Session("NameID") = Request.Form("NameID")
| >
| > Call it using
| > NameID = Session("NameID")
| > or in a new form field value using
| > <%=Session("NameID")%>
| >
| > See http://www.w3schools.com/asp/asp_sessions.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | have not been able to figure out how to make it work.
| > | The way I have it now (see this page:
| > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the search),
User
| > can write "Description"
| > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | database if they have a NameID and LName that match. Originally, I had the
| > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | NameID was lost once form was submitted to the database.
| > | Once they have entered the information, I want the user to be able to add
| > | additional events, without returning to the search page to get the parameter
| > | for NameID.
| > | The cookie should expire at the end of the session.
| > |
| > | Where would I find the syntax, or is it simple enough that someone could
| > | just give me the syntax, what page does it go in, and where in the page
| > | should it go?
| > |
| > | I appreciate any help, or any direction.
| >
| >
| >
 
C

ConnerS

The search.asp page is a "ASP Automatically generated by a Frontpage
Component" The form at the top is the Query included in the wizard. Once
the results are generated from the query, the name is hyperlinked with
parameters path=Add.asp and query string
NameID=<%=FP_FieldURL(fp_rs,"NameID")%> The confirmation page from the form
on Add.asp runs the custom query on RunTotal.asp

When I added this
<%
If NOT IsEmpty(Request.Form("NameID"))
Session("NameID") = Request.Form("NameID")
End if
%>
to the bottom of the Add.asp right before the </html> the the hyperlink to
Add.asp from Search.asp would no longer work. When I took it out, it worked
again. The beginning of Add.asp has this code: could it be interfering?
Thanks for being patient with me.
On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = "EnterHoursTemp.htm"

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("P_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Detail", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(4)
Dim arFormDBFields0(4)
Dim arFormValues0(4)

arFormFields0(0) = "NameID"
arFormDBFields0(0) = "NameID"
arFormValues0(0) = Request("NameID")
arFormFields0(1) = "HoursEvent"
arFormDBFields0(1) = "HoursEvent"
arFormValues0(1) = Request("HoursEvent")
arFormFields0(2) = "ServiceDate"
arFormDBFields0(2) = "ServiceDate"
arFormValues0(2) = Request("ServiceDate")
arFormFields0(3) = "Description"
arFormDBFields0(3) = "Description"
arFormValues0(3) = Request("Description")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0


fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "RunTotal.asp"

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>


Stefan B Rusynko said:
Your form at
http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
Has an ACTION="Search.asp"
- meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form

So in order to get a value for NameID the form needs to be sent at least once

Then anywhere in the receiving page check for the form field value and get it its value if it is not empty

<%
If NOT IsEmpty(Request.Form("NameID"))
Session("NameID") = Request.Form("NameID")
End if
%>

Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden field -
such as in the page AddMore.asp using

<input type="hidden" name="NameID" value="<%=Session("NameID")%>">


PS
You add VBScript by delimiting it as a script
- not by just entering it in a page as you apparently have after your </body> tag on Search.asp




|I see where the session variable is more what I want, thanks for the two
| links. What page and where on the page do I put the . (After the query on
| Search.asp is where the NameID is established)
| Session("NameID") = Request.Form("NameID")
| I put the <%=Session("NameID")%>
| as the hidden field in the form of AddMore.asp. the form works and writes
| the 3 text boxes, but not the NameID.
|
|
| "Stefan B Rusynko" wrote:
|
| > See http://www.w3schools.com/asp/asp_cookies.asp
| >
| > But I would recommend not using cookies
| > Instead use Session variables
| >
| > Create the Session variable using you form field as
| > Session("NameID") = Request.Form("NameID")
| >
| > Call it using
| > NameID = Session("NameID")
| > or in a new form field value using
| > <%=Session("NameID")%>
| >
| > See http://www.w3schools.com/asp/asp_sessions.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | have not been able to figure out how to make it work.
| > | The way I have it now (see this page:
| > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the search),
User
| > can write "Description"
| > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | database if they have a NameID and LName that match. Originally, I had the
| > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | NameID was lost once form was submitted to the database.
| > | Once they have entered the information, I want the user to be able to add
| > | additional events, without returning to the search page to get the parameter
| > | for NameID.
| > | The cookie should expire at the end of the session.
| > |
| > | Where would I find the syntax, or is it simple enough that someone could
| > | just give me the syntax, what page does it go in, and where in the page
| > | should it go?
| > |
| > | I appreciate any help, or any direction.
| >
| >
| >
 
S

Stefan B Rusynko

You need to add the code for the session variable at the top of the page (before the Head section) before any DBRW code and form on
Search.asp, Addmore.asp, or Add.asp
(whatever the 1st page that is processed by the 1st form that gets a value for that form field)

Test it by adding the following test line of code at the top of each page

<% Response.write "NameID = " & Session("NameID") & "<br>" %>

- obviously on the page w/ the code to create the session variable add it after that code



| The search.asp page is a "ASP Automatically generated by a Frontpage
| Component" The form at the top is the Query included in the wizard. Once
| the results are generated from the query, the name is hyperlinked with
| parameters path=Add.asp and query string
| NameID=<%=FP_FieldURL(fp_rs,"NameID")%> The confirmation page from the form
| on Add.asp runs the custom query on RunTotal.asp
|
| When I added this
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| to the bottom of the Add.asp right before the </html> the the hyperlink to
| Add.asp from Search.asp would no longer work. When I took it out, it worked
| again. The beginning of Add.asp has this code: could it be interfering?
| Thanks for being patient with me.
| On Error Resume Next
| Session("FP_OldCodePage") = Session.CodePage
| Session("FP_OldLCID") = Session.LCID
| Session.CodePage = 1252
| Err.Clear
|
| strErrorUrl = "EnterHoursTemp.htm"
|
| If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
| If Request.Form("VTI-GROUP") = "0" Then
| Err.Clear
|
| Set fp_conn = Server.CreateObject("ADODB.Connection")
| FP_DumpError strErrorUrl, "Cannot create connection"
|
| Set fp_rs = Server.CreateObject("ADODB.Recordset")
| FP_DumpError strErrorUrl, "Cannot create record set"
|
| fp_conn.Open Application("P_ConnectionString")
| FP_DumpError strErrorUrl, "Cannot open database"
|
| fp_rs.Open "Detail", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
| adCmdTable
| FP_DumpError strErrorUrl, "Cannot open record set"
|
| fp_rs.AddNew
| FP_DumpError strErrorUrl, "Cannot add new record set to the database"
| Dim arFormFields0(4)
| Dim arFormDBFields0(4)
| Dim arFormValues0(4)
|
| arFormFields0(0) = "NameID"
| arFormDBFields0(0) = "NameID"
| arFormValues0(0) = Request("NameID")
| arFormFields0(1) = "HoursEvent"
| arFormDBFields0(1) = "HoursEvent"
| arFormValues0(1) = Request("HoursEvent")
| arFormFields0(2) = "ServiceDate"
| arFormDBFields0(2) = "ServiceDate"
| arFormValues0(2) = Request("ServiceDate")
| arFormFields0(3) = "Description"
| arFormDBFields0(3) = "Description"
| arFormValues0(3) = Request("Description")
|
| FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
|
|
| fp_rs.Update
| FP_DumpError strErrorUrl, "Cannot update the database"
|
| fp_rs.Close
| fp_conn.Close
|
| Session("FP_SavedFields")=arFormFields0
| Session("FP_SavedValues")=arFormValues0
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
| Response.Redirect "RunTotal.asp"
|
| End If
| End If
|
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
|
| %>
|
|
| "Stefan B Rusynko" wrote:
|
| > Your form at
| > http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
| > Has an ACTION="Search.asp"
| > - meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
| > I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
| > NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form
| >
| > So in order to get a value for NameID the form needs to be sent at least once
| >
| > Then anywhere in the receiving page check for the form field value and get it its value if it is not empty
| >
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| >
| > Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden
field -
| > such as in the page AddMore.asp using
| >
| > <input type="hidden" name="NameID" value="<%=Session("NameID")%>">
| >
| >
| > PS
| > You add VBScript by delimiting it as a script
| > - not by just entering it in a page as you apparently have after your </body> tag on Search.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > |I see where the session variable is more what I want, thanks for the two
| > | links. What page and where on the page do I put the . (After the query on
| > | Search.asp is where the NameID is established)
| > | Session("NameID") = Request.Form("NameID")
| > | I put the <%=Session("NameID")%>
| > | as the hidden field in the form of AddMore.asp. the form works and writes
| > | the 3 text boxes, but not the NameID.
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > See http://www.w3schools.com/asp/asp_cookies.asp
| > | >
| > | > But I would recommend not using cookies
| > | > Instead use Session variables
| > | >
| > | > Create the Session variable using you form field as
| > | > Session("NameID") = Request.Form("NameID")
| > | >
| > | > Call it using
| > | > NameID = Session("NameID")
| > | > or in a new form field value using
| > | > <%=Session("NameID")%>
| > | >
| > | > See http://www.w3schools.com/asp/asp_sessions.asp
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > | > _____________________________________________
| > | >
| > | >
| > | > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | > | have not been able to figure out how to make it work.
| > | > | The way I have it now (see this page:
| > | > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the
search),
| > User
| > | > can write "Description"
| > | > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | > | database if they have a NameID and LName that match. Originally, I had the
| > | > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | > | NameID was lost once form was submitted to the database.
| > | > | Once they have entered the information, I want the user to be able to add
| > | > | additional events, without returning to the search page to get the parameter
| > | > | for NameID.
| > | > | The cookie should expire at the end of the session.
| > | > |
| > | > | Where would I find the syntax, or is it simple enough that someone could
| > | > | just give me the syntax, what page does it go in, and where in the page
| > | > | should it go?
| > | > |
| > | > | I appreciate any help, or any direction.
| > | >
| > | >
| > | >
| >
| >
| >
 
C

ConnerS

I think I am beginning to see how it works, but it is still not working, and
I am lost.
The page process is this:
Search -passes the NameID using parameters to
Add - uses hidden field to save NameID to table
Run Total -runs autoexec to save and add
Add more - is saving to table but without NameID
Run Total

So I put <%Session("NameID")= "NameID" %> on Add.asp right before the <html>
tag, but after the script that defines the database results (the page would
give me an error if I put it before that).

Then I have <%response.write(Session("NameID"))%> on the Search.asp and
RunTotal page
and <input type="hidden" name="NameID"
value=<%Response.write(Session("NameID"))%> on the addmore.asp

Still doesn't save to database table with NameID from the Addmore.asp page
Again, thank you!


Stefan B Rusynko said:
You need to add the code for the session variable at the top of the page (before the Head section) before any DBRW code and form on
Search.asp, Addmore.asp, or Add.asp
(whatever the 1st page that is processed by the 1st form that gets a value for that form field)

Test it by adding the following test line of code at the top of each page

<% Response.write "NameID = " & Session("NameID") & "<br>" %>

- obviously on the page w/ the code to create the session variable add it after that code



| The search.asp page is a "ASP Automatically generated by a Frontpage
| Component" The form at the top is the Query included in the wizard. Once
| the results are generated from the query, the name is hyperlinked with
| parameters path=Add.asp and query string
| NameID=<%=FP_FieldURL(fp_rs,"NameID")%> The confirmation page from the form
| on Add.asp runs the custom query on RunTotal.asp
|
| When I added this
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| to the bottom of the Add.asp right before the </html> the the hyperlink to
| Add.asp from Search.asp would no longer work. When I took it out, it worked
| again. The beginning of Add.asp has this code: could it be interfering?
| Thanks for being patient with me.
| On Error Resume Next
| Session("FP_OldCodePage") = Session.CodePage
| Session("FP_OldLCID") = Session.LCID
| Session.CodePage = 1252
| Err.Clear
|
| strErrorUrl = "EnterHoursTemp.htm"
|
| If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
| If Request.Form("VTI-GROUP") = "0" Then
| Err.Clear
|
| Set fp_conn = Server.CreateObject("ADODB.Connection")
| FP_DumpError strErrorUrl, "Cannot create connection"
|
| Set fp_rs = Server.CreateObject("ADODB.Recordset")
| FP_DumpError strErrorUrl, "Cannot create record set"
|
| fp_conn.Open Application("P_ConnectionString")
| FP_DumpError strErrorUrl, "Cannot open database"
|
| fp_rs.Open "Detail", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
| adCmdTable
| FP_DumpError strErrorUrl, "Cannot open record set"
|
| fp_rs.AddNew
| FP_DumpError strErrorUrl, "Cannot add new record set to the database"
| Dim arFormFields0(4)
| Dim arFormDBFields0(4)
| Dim arFormValues0(4)
|
| arFormFields0(0) = "NameID"
| arFormDBFields0(0) = "NameID"
| arFormValues0(0) = Request("NameID")
| arFormFields0(1) = "HoursEvent"
| arFormDBFields0(1) = "HoursEvent"
| arFormValues0(1) = Request("HoursEvent")
| arFormFields0(2) = "ServiceDate"
| arFormDBFields0(2) = "ServiceDate"
| arFormValues0(2) = Request("ServiceDate")
| arFormFields0(3) = "Description"
| arFormDBFields0(3) = "Description"
| arFormValues0(3) = Request("Description")
|
| FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
|
|
| fp_rs.Update
| FP_DumpError strErrorUrl, "Cannot update the database"
|
| fp_rs.Close
| fp_conn.Close
|
| Session("FP_SavedFields")=arFormFields0
| Session("FP_SavedValues")=arFormValues0
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
| Response.Redirect "RunTotal.asp"
|
| End If
| End If
|
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
|
| %>
|
|
| "Stefan B Rusynko" wrote:
|
| > Your form at
| > http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
| > Has an ACTION="Search.asp"
| > - meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
| > I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
| > NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form
| >
| > So in order to get a value for NameID the form needs to be sent at least once
| >
| > Then anywhere in the receiving page check for the form field value and get it its value if it is not empty
| >
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| >
| > Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden
field -
| > such as in the page AddMore.asp using
| >
| > <input type="hidden" name="NameID" value="<%=Session("NameID")%>">
| >
| >
| > PS
| > You add VBScript by delimiting it as a script
| > - not by just entering it in a page as you apparently have after your </body> tag on Search.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > |I see where the session variable is more what I want, thanks for the two
| > | links. What page and where on the page do I put the . (After the query on
| > | Search.asp is where the NameID is established)
| > | Session("NameID") = Request.Form("NameID")
| > | I put the <%=Session("NameID")%>
| > | as the hidden field in the form of AddMore.asp. the form works and writes
| > | the 3 text boxes, but not the NameID.
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > See http://www.w3schools.com/asp/asp_cookies.asp
| > | >
| > | > But I would recommend not using cookies
| > | > Instead use Session variables
| > | >
| > | > Create the Session variable using you form field as
| > | > Session("NameID") = Request.Form("NameID")
| > | >
| > | > Call it using
| > | > NameID = Session("NameID")
| > | > or in a new form field value using
| > | > <%=Session("NameID")%>
| > | >
| > | > See http://www.w3schools.com/asp/asp_sessions.asp
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > | > _____________________________________________
| > | >
| > | >
| > | > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | > | have not been able to figure out how to make it work.
| > | > | The way I have it now (see this page:
| > | > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the
search),
| > User
| > | > can write "Description"
| > | > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | > | database if they have a NameID and LName that match. Originally, I had the
| > | > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | > | NameID was lost once form was submitted to the database.
| > | > | Once they have entered the information, I want the user to be able to add
| > | > | additional events, without returning to the search page to get the parameter
| > | > | for NameID.
| > | > | The cookie should expire at the end of the session.
| > | > |
| > | > | Where would I find the syntax, or is it simple enough that someone could
| > | > | just give me the syntax, what page does it go in, and where in the page
| > | > | should it go?
| > | > |
| > | > | I appreciate any help, or any direction.
| > | >
| > | >
| > | >
| >
| >
| >
 
M

MikeR

change
<input type="hidden" name="NameID"> value=<%Response.write(Session("NameID"))%>
to
<input type="hidden" name="NameID"> value=<%=(Session("NameID"))%>

response.write displays whatever the parameter you give it is. response.write("Conner")
shows Connor on the page

MikeR 1st
I think I am beginning to see how it works, but it is still not working, and
I am lost.
The page process is this:
Search -passes the NameID using parameters to
Add - uses hidden field to save NameID to table
Run Total -runs autoexec to save and add
Add more - is saving to table but without NameID
Run Total

So I put <%Session("NameID")= "NameID" %> on Add.asp right before the <html>
tag, but after the script that defines the database results (the page would
give me an error if I put it before that).

Then I have <%response.write(Session("NameID"))%> on the Search.asp and
RunTotal page
and <input type="hidden" name="NameID"
value=<%Response.write(Session("NameID"))%> on the addmore.asp

Still doesn't save to database table with NameID from the Addmore.asp page
Again, thank you!


:

You need to add the code for the session variable at the top of the page (before the Head section) before any DBRW code and form on
Search.asp, Addmore.asp, or Add.asp
(whatever the 1st page that is processed by the 1st form that gets a value for that form field)

Test it by adding the following test line of code at the top of each page

<% Response.write "NameID = " & Session("NameID") & "<br>" %>

- obviously on the page w/ the code to create the session variable add it after that code



| The search.asp page is a "ASP Automatically generated by a Frontpage
| Component" The form at the top is the Query included in the wizard. Once
| the results are generated from the query, the name is hyperlinked with
| parameters path=Add.asp and query string
| NameID=<%=FP_FieldURL(fp_rs,"NameID")%> The confirmation page from the form
| on Add.asp runs the custom query on RunTotal.asp
|
| When I added this
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| to the bottom of the Add.asp right before the </html> the the hyperlink to
| Add.asp from Search.asp would no longer work. When I took it out, it worked
| again. The beginning of Add.asp has this code: could it be interfering?
| Thanks for being patient with me.
| On Error Resume Next
| Session("FP_OldCodePage") = Session.CodePage
| Session("FP_OldLCID") = Session.LCID
| Session.CodePage = 1252
| Err.Clear
|
| strErrorUrl = "EnterHoursTemp.htm"
|
| If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
| If Request.Form("VTI-GROUP") = "0" Then
| Err.Clear
|
| Set fp_conn = Server.CreateObject("ADODB.Connection")
| FP_DumpError strErrorUrl, "Cannot create connection"
|
| Set fp_rs = Server.CreateObject("ADODB.Recordset")
| FP_DumpError strErrorUrl, "Cannot create record set"
|
| fp_conn.Open Application("P_ConnectionString")
| FP_DumpError strErrorUrl, "Cannot open database"
|
| fp_rs.Open "Detail", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
| adCmdTable
| FP_DumpError strErrorUrl, "Cannot open record set"
|
| fp_rs.AddNew
| FP_DumpError strErrorUrl, "Cannot add new record set to the database"
| Dim arFormFields0(4)
| Dim arFormDBFields0(4)
| Dim arFormValues0(4)
|
| arFormFields0(0) = "NameID"
| arFormDBFields0(0) = "NameID"
| arFormValues0(0) = Request("NameID")
| arFormFields0(1) = "HoursEvent"
| arFormDBFields0(1) = "HoursEvent"
| arFormValues0(1) = Request("HoursEvent")
| arFormFields0(2) = "ServiceDate"
| arFormDBFields0(2) = "ServiceDate"
| arFormValues0(2) = Request("ServiceDate")
| arFormFields0(3) = "Description"
| arFormDBFields0(3) = "Description"
| arFormValues0(3) = Request("Description")
|
| FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
|
|
| fp_rs.Update
| FP_DumpError strErrorUrl, "Cannot update the database"
|
| fp_rs.Close
| fp_conn.Close
|
| Session("FP_SavedFields")=arFormFields0
| Session("FP_SavedValues")=arFormValues0
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
| Response.Redirect "RunTotal.asp"
|
| End If
| End If
|
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
|
| %>
|
|
| "Stefan B Rusynko" wrote:
|
| > Your form at
| > http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
| > Has an ACTION="Search.asp"
| > - meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
| > I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
| > NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form
| >
| > So in order to get a value for NameID the form needs to be sent at least once
| >
| > Then anywhere in the receiving page check for the form field value and get it its value if it is not empty
| >
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| >
| > Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden
field -
| > such as in the page AddMore.asp using
| >
| > <input type="hidden" name="NameID" value="<%=Session("NameID")%>">
| >
| >
| > PS
| > You add VBScript by delimiting it as a script
| > - not by just entering it in a page as you apparently have after your </body> tag on Search.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > |I see where the session variable is more what I want, thanks for the two
| > | links. What page and where on the page do I put the . (After the query on
| > | Search.asp is where the NameID is established)
| > | Session("NameID") = Request.Form("NameID")
| > | I put the <%=Session("NameID")%>
| > | as the hidden field in the form of AddMore.asp. the form works and writes
| > | the 3 text boxes, but not the NameID.
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > See http://www.w3schools.com/asp/asp_cookies.asp
| > | >
| > | > But I would recommend not using cookies
| > | > Instead use Session variables
| > | >
| > | > Create the Session variable using you form field as
| > | > Session("NameID") = Request.Form("NameID")
| > | >
| > | > Call it using
| > | > NameID = Session("NameID")
| > | > or in a new form field value using
| > | > <%=Session("NameID")%>
| > | >
| > | > See http://www.w3schools.com/asp/asp_sessions.asp
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > | > _____________________________________________
| > | >
| > | >
| > | > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | > | have not been able to figure out how to make it work.
| > | > | The way I have it now (see this page:
| > | > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the
search),
| > User
| > | > can write "Description"
| > | > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | > | database if they have a NameID and LName that match. Originally, I had the
| > | > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | > | NameID was lost once form was submitted to the database.
| > | > | Once they have entered the information, I want the user to be able to add
| > | > | additional events, without returning to the search page to get the parameter
| > | > | for NameID.
| > | > | The cookie should expire at the end of the session.
| > | > |
| > | > | Where would I find the syntax, or is it simple enough that someone could
| > | > | just give me the syntax, what page does it go in, and where in the page
| > | > | should it go?
| > | > |
| > | > | I appreciate any help, or any direction.
| > | >
| > | >
| > | >
| >
| >
| >
 
C

ConnerS

I still can't get it to work. It will show the NameID on the RunTotal page,
but not on the Addmore.asp. I tried not hiding it and it still won't show or
write to the database.

MikeR said:
change
<input type="hidden" name="NameID"> value=<%Response.write(Session("NameID"))%>
to
<input type="hidden" name="NameID"> value=<%=(Session("NameID"))%>

response.write displays whatever the parameter you give it is. response.write("Conner")
shows Connor on the page

MikeR 1st
I think I am beginning to see how it works, but it is still not working, and
I am lost.
The page process is this:
Search -passes the NameID using parameters to
Add - uses hidden field to save NameID to table
Run Total -runs autoexec to save and add
Add more - is saving to table but without NameID
Run Total

So I put <%Session("NameID")= "NameID" %> on Add.asp right before the <html>
tag, but after the script that defines the database results (the page would
give me an error if I put it before that).

Then I have <%response.write(Session("NameID"))%> on the Search.asp and
RunTotal page
and <input type="hidden" name="NameID"
value=<%Response.write(Session("NameID"))%> on the addmore.asp

Still doesn't save to database table with NameID from the Addmore.asp page
Again, thank you!


:

You need to add the code for the session variable at the top of the page (before the Head section) before any DBRW code and form on
Search.asp, Addmore.asp, or Add.asp
(whatever the 1st page that is processed by the 1st form that gets a value for that form field)

Test it by adding the following test line of code at the top of each page

<% Response.write "NameID = " & Session("NameID") & "<br>" %>

- obviously on the page w/ the code to create the session variable add it after that code



| The search.asp page is a "ASP Automatically generated by a Frontpage
| Component" The form at the top is the Query included in the wizard. Once
| the results are generated from the query, the name is hyperlinked with
| parameters path=Add.asp and query string
| NameID=<%=FP_FieldURL(fp_rs,"NameID")%> The confirmation page from the form
| on Add.asp runs the custom query on RunTotal.asp
|
| When I added this
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| to the bottom of the Add.asp right before the </html> the the hyperlink to
| Add.asp from Search.asp would no longer work. When I took it out, it worked
| again. The beginning of Add.asp has this code: could it be interfering?
| Thanks for being patient with me.
| On Error Resume Next
| Session("FP_OldCodePage") = Session.CodePage
| Session("FP_OldLCID") = Session.LCID
| Session.CodePage = 1252
| Err.Clear
|
| strErrorUrl = "EnterHoursTemp.htm"
|
| If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
| If Request.Form("VTI-GROUP") = "0" Then
| Err.Clear
|
| Set fp_conn = Server.CreateObject("ADODB.Connection")
| FP_DumpError strErrorUrl, "Cannot create connection"
|
| Set fp_rs = Server.CreateObject("ADODB.Recordset")
| FP_DumpError strErrorUrl, "Cannot create record set"
|
| fp_conn.Open Application("P_ConnectionString")
| FP_DumpError strErrorUrl, "Cannot open database"
|
| fp_rs.Open "Detail", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
| adCmdTable
| FP_DumpError strErrorUrl, "Cannot open record set"
|
| fp_rs.AddNew
| FP_DumpError strErrorUrl, "Cannot add new record set to the database"
| Dim arFormFields0(4)
| Dim arFormDBFields0(4)
| Dim arFormValues0(4)
|
| arFormFields0(0) = "NameID"
| arFormDBFields0(0) = "NameID"
| arFormValues0(0) = Request("NameID")
| arFormFields0(1) = "HoursEvent"
| arFormDBFields0(1) = "HoursEvent"
| arFormValues0(1) = Request("HoursEvent")
| arFormFields0(2) = "ServiceDate"
| arFormDBFields0(2) = "ServiceDate"
| arFormValues0(2) = Request("ServiceDate")
| arFormFields0(3) = "Description"
| arFormDBFields0(3) = "Description"
| arFormValues0(3) = Request("Description")
|
| FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
|
|
| fp_rs.Update
| FP_DumpError strErrorUrl, "Cannot update the database"
|
| fp_rs.Close
| fp_conn.Close
|
| Session("FP_SavedFields")=arFormFields0
| Session("FP_SavedValues")=arFormValues0
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
| Response.Redirect "RunTotal.asp"
|
| End If
| End If
|
| Session.CodePage = Session("FP_OldCodePage")
| Session.LCID = Session("FP_OldLCID")
|
| %>
|
|
| "Stefan B Rusynko" wrote:
|
| > Your form at
| > http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp
| > Has an ACTION="Search.asp"
| > - meaning your form is processed by ASP code in the same page After the form results are sent to the same page again
| > I suspect from your post it should be sending the form action to AddMore.asp, not Search.asp
| > NameID is a current text field in your form (not a hidden field) that you want to send to some other page/form
| >
| > So in order to get a value for NameID the form needs to be sent at least once
| >
| > Then anywhere in the receiving page check for the form field value and get it its value if it is not empty
| >
| > <%
| > If NOT IsEmpty(Request.Form("NameID"))
| > Session("NameID") = Request.Form("NameID")
| > End if
| > %>
| >
| > Now the value of Session(NameID") is available to any page during the active session and can be used in any form as a hidden
field -
| > such as in the page AddMore.asp using
| >
| > <input type="hidden" name="NameID" value="<%=Session("NameID")%>">
| >
| >
| > PS
| > You add VBScript by delimiting it as a script
| > - not by just entering it in a page as you apparently have after your </body> tag on Search.asp
| >
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > _____________________________________________
| >
| >
| > |I see where the session variable is more what I want, thanks for the two
| > | links. What page and where on the page do I put the . (After the query on
| > | Search.asp is where the NameID is established)
| > | Session("NameID") = Request.Form("NameID")
| > | I put the <%=Session("NameID")%>
| > | as the hidden field in the form of AddMore.asp. the form works and writes
| > | the 3 text boxes, but not the NameID.
| > |
| > |
| > | "Stefan B Rusynko" wrote:
| > |
| > | > See http://www.w3schools.com/asp/asp_cookies.asp
| > | >
| > | > But I would recommend not using cookies
| > | > Instead use Session variables
| > | >
| > | > Create the Session variable using you form field as
| > | > Session("NameID") = Request.Form("NameID")
| > | >
| > | > Call it using
| > | > NameID = Session("NameID")
| > | > or in a new form field value using
| > | > <%=Session("NameID")%>
| > | >
| > | > See http://www.w3schools.com/asp/asp_sessions.asp
| > | >
| > | > --
| > | >
| > | > _____________________________________________
| > | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | > "Warning - Using the F1 Key will not break anything!" (-;
| > | > To find the best Newsgroup for FrontPage support see:
| > | > http://www.net-sites.com/sitebuilder/newsgroups.asp
| > | > _____________________________________________
| > | >
| > | >
| > | > | According to my Frontpage 2002 Developers guide, I can use cookies to save a
| > | > | parameter to be used in ASP pages. The guide is just vague enough that I
| > | > | have not been able to figure out how to make it work.
| > | > | The way I have it now (see this page:
| > | > | http://www.diocesephoenix.org/school/seton_catholic_hs/Parents/Hours/Search.asp with ID 2000000 and student as the
search),
| > User
| > | > can write "Description"
| > | > | "ServiceDate" and "Hours" using a form with the NameID hidden, to a Access
| > | > | database if they have a NameID and LName that match. Originally, I had the
| > | > | confirmation page with a link back to the Add.asp page, but the parameter for
| > | > | NameID was lost once form was submitted to the database.
| > | > | Once they have entered the information, I want the user to be able to add
| > | > | additional events, without returning to the search page to get the parameter
| > | > | for NameID.
| > | > | The cookie should expire at the end of the session.
| > | > |
| > | > | Where would I find the syntax, or is it simple enough that someone could
| > | > | just give me the syntax, what page does it go in, and where in the page
| > | > | should it go?
| > | > |
| > | > | I appreciate any help, or any direction.
| > | >
| > | >
| > | >
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top