Form - How can I maintain state?

Results 1 to 5 of 5

Thread: Form - How can I maintain state?

  1. #1
    John D. Guest

    Default Form - How can I maintain state?

    I have a fairly straightforward form page I am putting together for a project. I have a form page that has entry fields for quantity, part number, name, address, city, etc.<BR>The form is like a shopping cart, where the visitor can navigate through the catalog and add 1 or more items to the form along with shipping information.<BR>The problem is that the form is cleared each time the visitor leaves the form page, navigates the catalog and returns to the form via a hyperlink to the form from different asp pages.<BR>From the information I have gathered on this subject from this and other web sites, it appears that the form is losing "state".<BR>I have found various snippets of code examples, cookies, but nothing comprehensive and straightforward.<BR>I am rather new to asp and scripting and I would greatly appreciate if anyone can help.<BR>Thanks in advance,<BR>John

  2. #2
    Keith Fowler Guest

    Default RE: Form - How can I maintain state?

    Well, John! Welcome to the ASP world. Glad to have you. You will want to investigate the many resources available out here in cyberspace. During your investigation, look for information on the Application Object and the Session Object. Through these two wonderful objs you can maintain state throughout the App, or the Session. One place to start is www.learnasp.com.

  3. #3
    John D. Guest

    Default RE: Form - How can I maintain state?

    Keith, thanks prompt for the reply! I have looked at the learnasp.com site and they do have good info there, However, I have added the code samples and modified it for my form. Unfortunately, it does not seem to work. I am not sure "what goes where". Is there a sample file that you know of that clearly illustrates where the objects are placed in the htm code?.<BR>The other uncertainty on my for is the string: &#060;input type="text" name="Qty1" size="4" value="&#060;% = Qty1%&#062;"&#062;<BR>On my form, I have many fields. This string is for the first quantity entry field.<BR>From what I understand at this point, I need to assign a value to the user input field for quantity... value="&#060;% = Qty1%&#062;"<BR>Within the &#060;body&#062; tag I have:<BR>&#060;%<BR>Qty1 = Request.Form("Qty1")<BR>%&#062;<BR>I do not know what to use to start the session state to get the value of ("Qty1").<BR>I have tried: &#060;%<BR>response.buffer=true<BR>%&#062;<BR>D o I need something prior to this like:<BR>&#060;html&#062; <BR>&#060;body&#062; <BR> &#060;form action="cookie.asp" method="post"&#062; <BR> Name: <BR> &#060;input type="text" name="Qty1" size="4"&#062; <BR> &#060;input type="submit" value="submit"&#062; <BR> &#060;/form&#062; <BR>&#060;/body&#062; <BR>&#060;/html&#062; <BR>(this is from the example: http://www.4guysfromrolla.com/webtech/051099-1.shtml)on this site.<BR><BR>The other property that I am not sure of is the domain.<BR>I am running PWS on NT locally to build and test the site.<BR>Do I use localhost (mypcname) as the domain to test, then change it to the live server domain name?<BR><BR>I know I asked a lot of questions, sorry, but if you think you may be able to steer me in the right direction without a lot of time & effort on your part, I would be sincerely grateful.<BR>My thanks again,<BR>John

  4. #4
    Keith Fowler Guest

    Default RE: Form - How can I maintain state?

    Basically your form should be separate from your ASP file, unless of course you build a recursive ASP file, but that&#039s a little more advanced.<BR><BR>Start by building your form page as you would any other page. Do not use any scripting on it. The intial form tag should look like the following:<BR>&#060;Form ACTION="pagetitle.asp" METHOD="POST"&#062;<BR><BR>Keep it like the example code you found, basically.<BR><BR>Then create your ASP file to do the processing you need.<BR>&#060;%@ Language="VBScript"%&#062;<BR>&#060;% Response.Buffer = True<BR> Option Explicit %&#062;<BR><BR>&#060;%<BR> Dim QTY1<BR><BR> QTY1 = Request.Form("QTY1")<BR> Session("QTY") = QTY1 &#039This creates your Session Variable<BR><BR>&#039Perform whatever actions you need.<BR><BR>%&#062;<BR>It is fine to test on PWS. After you have tested out your application, transfer it to your LIVE web server and test it again!<BR><BR>Glad to be of help! If you need anything further, don&#039t hesitate to ask. I check the board at different times throughout the day, so I may not be able to get back to you on a timely basis. As I always say, any help is good help!


  5. #5
    John D. Guest

    Default RE: Form - How can I maintain state?

    Keith,<BR>Thanks for the reply! I tried your suggestion and code sample, but, I think I need a little more usderstanding of the relationship between the form and the asp file that does the processing.<BR><BR>On my form, where you stated:<BR>&#060;Form ACTION="pagetitle.asp" METHOD="POST"&#062;<BR><BR>Each time I submit the form, it goes to itself, not the confirmation page.<BR><BR>The next code you gave me to create the ASP file to process the code:<BR>&#060;%@ Language="VBScript"%&#062;<BR>&#060;% Response.Buffer = True<BR>Option Explicit %&#062;<BR><BR>&#060;%<BR>Dim QTY1<BR><BR>QTY1 = Request.Form("QTY1")<BR>Session("QTY") = QTY1 &#039This creates your Session Variable<BR><BR>&#039Perform whatever actions you need.<BR><BR>%&#062;<BR><BR>I really don&#039t know where this ASP page goes or what it should be called. I also don&#039t know how it can relate to the form.<BR>There is a problem with the Option Explicit line, it generates an error message on my browser.<BR><BR>Would it help if I sent you the web address of the site so that you can see how the content pages launch the order form?<BR>Send a reply to me at imsadv@en.com<BR>Thanks Keith, I hope to hear from you.<BR>John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •