ASP code in a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Raman Pahwa
    New Member
    • Jul 2008
    • 43

    ASP code in a form

    I have an ASP code with a form in that.I have 2 text boxes and a submit button.I enter data in text boxes and then click on submit. then action I want takes place.but when i go to previous page to change the data in text boxes.the data entered earlier get lost.I want to keep that data so that i can know what data has been entered first and which data is to be entered next.

    Plz guide me.
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Classic ASP doesn't persist user-entered information, if that's what you're after. If you need that functionality then move to ASP.NET.

    codegecko

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Hello Everyone,

      Sorry for not being more active on the boards. I have been very busy!! Well, I am back now.

      @Raman: Codegrcko is correct. But, there are was to skin your cat </grin>. Because this is a Classic ASP forum lets see if we can give you some “Classic” suggestions on how to resolve your question.

      If I understand your dilemma; you have two pages. The first is a </form> page that you have people enter information. The second page is a processing page that takes form elements from the first page and does something with them. Simple enough so far; well, till you want the people to have the ability to go back to the first page and edit the data they submitted. This is where you seem to have a problem.

      Below are just two examples out of a hundred that could be posted here.

      This first example just posts the information back to itself thus combining the two pages into one. Look at line 7 and there you can see the post action posting back to itself. On line 8 and 9 are the two form elements that a user would fill out. Also, one the same two lines you can also see that the initial value for the elements are set to be a value that is being passed in via a </form>. Line 6 is processing any form elements that were passed in to the page.

      So, in the below example if you were to run it; the first thing you would see is a form with three elements (two text boxes and the submit button). If you filled out the form and clicked the submit button then the page would post to itself and you would see your first and last name at the top of the page and then you would see a form with three elements (two text boxes and the submit button). The two text box elements would be filled in with the information that you typed in before.

      Code:
      <html>
      	<head>
      		<title>Raman Pahwa's test page (index.asp)</title>
      	</head>
      	<body>
      		<%Response.Write(Request.Form("xFristName") & " " & Response.Write(Request.Form("xLastName"))%>
      		<form id="xForm" name="xForm" method="post" action="index.asp">
      			<input type="text" name="xFristName" size="50" value="<%Response.Write(Request.Form("xFristName"))%>">
      			<input type="text" name="xLastName" size="50" value="<%Response.Write(Request.Form("xLastName"))%>">
      			<input type="submit" value="Submit" name="xSubmit">
      		</form>
      	</body>
      </html>

      This second example is more inline with your dilemma where the post goes to another page.

      On “PageOne.asp” look at line 6 and there you can see the post action is posting to PageTwo.asp. On line 7 and 8 are the two form elements that a user would fill out. Also, one the same two lines you can also see that the initial value for the elements are set to be a value that is being passed in via a </form>.

      On “PageTwo.asp” look at Line 6 it is processing any form elements that were passed in to the page. On line 8 and 9 are the two HIDDEN form elements that are pre-filled by values that is being passed in via a </form>.

      In this example there are two pages (PageOne.asp and PageTwo.asp). If you ran this example you would see on the first page a form with three elements (two text boxes and the submit button). If you filled out the form and clicked the submit button then the page would post to PageTwo.asp. On PageTwo.asp you would see your first and last name at the top of the page and then you would only see a submit button titled “return”. If you were to click on the return button you would be redirected to PageOne.asp and the whole process would start over except that the two text box elements would be filled in with the information that you typed in before.

      PageOne.asp:
      Code:
      <html>
      	<head>
      		<title>Raman Pahwa's test page (PageOne.asp)</title>
      	</head>
      	<body>
      		<form id="xForm" name="xForm" method="post" action="PageTwo.asp">
      			<input type="text" name="xFristName" size="50" value="<%Response.Write(Request.Form("xFristName"))%>">
      			<input type="text" name="xLastName" size="50" value="<%Response.Write(Request.Form("xLastName"))%>">
      			<input type="submit" value="Submit" name="xSubmit">
      		</form>
      	</body>
      </html>

      PageTwo.asp:
      Code:
      <html>
      	<head>
      		<title>Raman Pahwa's test page (PageTwo.asp)</title>
      	</head>
      	<body>
      		<%Response.Write(Request.Form("xFristName") & " " & Response.Write(Request.Form("xLastName"))%>
      		<form id="yForm" name="yForm" method="post" action="PageOne.asp">
      			<input type="hidden" name="yFristName" value="<%Response.Write(Request.Form("xFristName"))%>">
      			<input type="hidden" name="yLastName" value="<%Response.Write(Request.Form("xLastName"))%>">
      			<input type="submit" value="Return" name="ySubmit">
      		</form>
      	</body>
      </html>

      Hope this helps,
      CroCrew~

      Comment

      • Raman Pahwa
        New Member
        • Jul 2008
        • 43

        #4
        Originally posted by codegecko
        Classic ASP doesn't persist user-entered information, if that's what you're after. If you need that functionality then move to ASP.NET.

        codegecko
        Earlier it was working fine.but its creating problem from 2-3 days.

        Comment

        • Raman Pahwa
          New Member
          • Jul 2008
          • 43

          #5
          Originally posted by CroCrew
          Hello Everyone,

          Sorry for not being more active on the boards. I have been very busy!! Well, I am back now.

          @Raman: Codegrcko is correct. But, there are was to skin your cat </grin>. Because this is a Classic ASP forum lets see if we can give you some “Classic” suggestions on how to resolve your question.

          If I understand your dilemma; you have two pages. The first is a </form> page that you have people enter information. The second page is a processing page that takes form elements from the first page and does something with them. Simple enough so far; well, till you want the people to have the ability to go back to the first page and edit the data they submitted. This is where you seem to have a problem.

          Below are just two examples out of a hundred that could be posted here.

          This first example just posts the information back to itself thus combining the two pages into one. Look at line 7 and there you can see the post action posting back to itself. On line 8 and 9 are the two form elements that a user would fill out. Also, one the same two lines you can also see that the initial value for the elements are set to be a value that is being passed in via a </form>. Line 6 is processing any form elements that were passed in to the page.

          So, in the below example if you were to run it; the first thing you would see is a form with three elements (two text boxes and the submit button). If you filled out the form and clicked the submit button then the page would post to itself and you would see your first and last name at the top of the page and then you would see a form with three elements (two text boxes and the submit button). The two text box elements would be filled in with the information that you typed in before.

          Code:
          <html>
          	<head>
          		<title>Raman Pahwa's test page (index.asp)</title>
          	</head>
          	<body>
          		<%Response.Write(Request.Form("xFristName") & " " & Response.Write(Request.Form("xLastName"))%>
          		<form id="xForm" name="xForm" method="post" action="index.asp">
          			<input type="text" name="xFristName" size="50" value="<%Response.Write(Request.Form("xFristName"))%>">
          			<input type="text" name="xLastName" size="50" value="<%Response.Write(Request.Form("xLastName"))%>">
          			<input type="submit" value="Submit" name="xSubmit">
          		</form>
          	</body>
          </html>

          This second example is more inline with your dilemma where the post goes to another page.

          On “PageOne.asp” look at line 6 and there you can see the post action is posting to PageTwo.asp. On line 7 and 8 are the two form elements that a user would fill out. Also, one the same two lines you can also see that the initial value for the elements are set to be a value that is being passed in via a </form>.

          On “PageTwo.asp” look at Line 6 it is processing any form elements that were passed in to the page. On line 8 and 9 are the two HIDDEN form elements that are pre-filled by values that is being passed in via a </form>.

          In this example there are two pages (PageOne.asp and PageTwo.asp). If you ran this example you would see on the first page a form with three elements (two text boxes and the submit button). If you filled out the form and clicked the submit button then the page would post to PageTwo.asp. On PageTwo.asp you would see your first and last name at the top of the page and then you would only see a submit button titled “return”. If you were to click on the return button you would be redirected to PageOne.asp and the whole process would start over except that the two text box elements would be filled in with the information that you typed in before.

          PageOne.asp:
          Code:
          <html>
          	<head>
          		<title>Raman Pahwa's test page (PageOne.asp)</title>
          	</head>
          	<body>
          		<form id="xForm" name="xForm" method="post" action="PageTwo.asp">
          			<input type="text" name="xFristName" size="50" value="<%Response.Write(Request.Form("xFristName"))%>">
          			<input type="text" name="xLastName" size="50" value="<%Response.Write(Request.Form("xLastName"))%>">
          			<input type="submit" value="Submit" name="xSubmit">
          		</form>
          	</body>
          </html>

          PageTwo.asp:
          Code:
          <html>
          	<head>
          		<title>Raman Pahwa's test page (PageTwo.asp)</title>
          	</head>
          	<body>
          		<%Response.Write(Request.Form("xFristName") & " " & Response.Write(Request.Form("xLastName"))%>
          		<form id="yForm" name="yForm" method="post" action="PageOne.asp">
          			<input type="hidden" name="yFristName" value="<%Response.Write(Request.Form("xFristName"))%>">
          			<input type="hidden" name="yLastName" value="<%Response.Write(Request.Form("xLastName"))%>">
          			<input type="submit" value="Return" name="ySubmit">
          		</form>
          	</body>
          </html>

          Hope this helps,
          CroCrew~


          I have only a single page.and I have tried ur code,but the data still is getting lost.

          Comment

          • Raman Pahwa
            New Member
            • Jul 2008
            • 43

            #6
            I have only a single page.and I have tried ur code,but the data still is getting lost.Plz guide.

            Comment

            • CroCrew
              Recognized Expert Contributor
              • Jan 2008
              • 564

              #7
              Please post your code so that we can see what needs to be fixed.

              Thanks,
              CroCrew~

              Comment

              • Raman Pahwa
                New Member
                • Jul 2008
                • 43

                #8
                The Code which I have with me was working fine earlier.but its creating problem from 2-3 days.Secondly, I have two explorers, one is IE and 2nd is Mozilla.Its working fine in Mozilla but not in IE.As I mostly use IE on my system.plz help.

                Comment

                • CroCrew
                  Recognized Expert Contributor
                  • Jan 2008
                  • 564

                  #9
                  Again, we need to see your code to able to fix it. Please post your code so that we can help.

                  Thanks,
                  CroCrew~

                  Comment

                  • Raman Pahwa
                    New Member
                    • Jul 2008
                    • 43

                    #10
                    Originally posted by CroCrew
                    Again, we need to see your code to able to fix it. Please post your code so that we can help.

                    Thanks,
                    CroCrew~
                    <html>
                    <body>
                    <form name="a" action="Pro10.a sp?Data=1" method="post">
                    <Br>
                    <Table>
                    <TR><TD>Messa ge to be Sent</TD><TD><input type="text" name="URL1" value="" size=180></TD></TR>
                    <TR><TD>Path and name of XLS </TD><TD>
                    <input type="Text" name="URL3" value="" size="100"></TD></TR>
                    <BR>
                    <BR>
                    <TR><Td>&nbsp ;</td><td><input type="submit" value="Generate " ></td></TR>
                    </Table>
                    </form>
                    <%
                    end if
                    %>

                    </body>
                    </html>

                    Comment

                    • CroCrew
                      Recognized Expert Contributor
                      • Jan 2008
                      • 564

                      #11
                      Hello Raman Pahwa,

                      What is the name of the page you just posted the code for? Also, could you please post the code for the page you have called “Pro10.asp” I know that after you supply this information that we will have a solution for you.

                      Thanks,
                      CroCrew~

                      Comment

                      Working...