|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Richard Mueller... you out there?with the latest problem that we can't seem to fix. Consider an ASP page with a form that has a few text fields... name, address, comments etc. The page posts to itself so we have the usual line that says: If Request.ServerVariables("REQUEST_METHOD") = "POST" Then If the users input passes various validations we write it to a database and display a thank you message below the form. The problem is when a validation fails. When that happens we display a sorry, try again kind of message, but the problem is that the page refreshes and the users data that they typed in is cleared form the text boxes. We want the data to persist until the form is successfully submitted, then it can clear (because this is what a user expects when the form is submitted. If the data persisted after success, they would get confused and probably resubmit it) We've tried different functions in conjunction with setting the default value of the text boxes to: <%= Request.Form("textboxname") %>, but the best we can get is for the data to persist, regardless of whether the submission is good or not. Is there anything clever you can come up with? If I have to I can put an example on the web. Thank you!
Show quote
Hide quote
"Jim D" <no@spam.com> wrote in message This works:-news:%23%23mXdYw6GHA.3836@TK2MSFTNGP02.phx.gbl... > Hi Richard. You've helped me out in the past so I thought I'd present you > with the latest problem that we can't seem to fix. > > Consider an ASP page with a form that has a few text fields... name, > address, comments etc. The page posts to itself so we have the usual line > that says: > > If Request.ServerVariables("REQUEST_METHOD") = "POST" Then > > If the users input passes various validations we write it to a database and > display a thank you message below the form. The problem is when a validation > fails. When that happens we display a sorry, try again kind of message, but > the problem is that the page refreshes and the users data that they typed in > is cleared form the text boxes. We want the data to persist until the form > is successfully submitted, then it can clear (because this is what a user > expects when the form is submitted. If the data persisted after success, > they would get confused and probably resubmit it) > > We've tried different functions in conjunction with setting the default > value of the text boxes to: > <%= Request.Form("textboxname") %>, but the best we can get is for the data > to persist, regardless of whether the submission is good or not. > > Is there anything clever you can come up with? If I have to I can put an > example on the web. > > Thank you! <% Dim mbFailed : mbFailed = True If Request.ServerVariables("REQUEST_METHOD") = "POST" Then mbFailed = LCase(Request.Form("field1")) <> "bad" End If %> <html> <body> <form method="POST" action="test.asp"> <input name="field1" value="<%=GetDefault("field1")%>" /> <input type="submit" value="Post" /></body> </html> <% Function GetDefault(Name) If Not mbFailed Then GetDefault = Server.HTMLEncode(Request.Form(Name)) End If End Function %> It's same as the other one I posted only it uses the more tranditional REQUEST_METHOD instead of HTTP_METHOD which are actually the same thing. ;) got it working. thanks everyone
Show quoteHide quote "Anthony Jones" <A**@yadayadayada.com> wrote in message news:exkDOL46GHA.4620@TK2MSFTNGP02.phx.gbl... > > "Jim D" <no@spam.com> wrote in message > news:%23%23mXdYw6GHA.3836@TK2MSFTNGP02.phx.gbl... >> Hi Richard. You've helped me out in the past so I thought I'd present you >> with the latest problem that we can't seem to fix. >> >> Consider an ASP page with a form that has a few text fields... name, >> address, comments etc. The page posts to itself so we have the usual line >> that says: >> >> If Request.ServerVariables("REQUEST_METHOD") = "POST" Then >> >> If the users input passes various validations we write it to a database > and >> display a thank you message below the form. The problem is when a > validation >> fails. When that happens we display a sorry, try again kind of message, > but >> the problem is that the page refreshes and the users data that they typed > in >> is cleared form the text boxes. We want the data to persist until the >> form >> is successfully submitted, then it can clear (because this is what a user >> expects when the form is submitted. If the data persisted after success, >> they would get confused and probably resubmit it) >> >> We've tried different functions in conjunction with setting the default >> value of the text boxes to: >> <%= Request.Form("textboxname") %>, but the best we can get is for the > data >> to persist, regardless of whether the submission is good or not. >> >> Is there anything clever you can come up with? If I have to I can put an >> example on the web. >> >> Thank you! > > This works:- > > <% > > Dim mbFailed : mbFailed = True > > If Request.ServerVariables("REQUEST_METHOD") = "POST" Then > mbFailed = LCase(Request.Form("field1")) <> "bad" > End If > > %> > <html> > <body> > <form method="POST" action="test.asp"> > <input name="field1" value="<%=GetDefault("field1")%>" /> > <input type="submit" value="Post" /> > </body> > </html> > <% > Function GetDefault(Name) > If Not mbFailed Then > GetDefault = Server.HTMLEncode(Request.Form(Name)) > End If > End Function > %> > > It's same as the other one I posted only it uses the more tranditional > REQUEST_METHOD instead of HTTP_METHOD which are actually the same thing. > ;) > > >
Other interesting topics
retreiving data from html page
Quizz script performance bug -- too many questions? interesting problem... call store procedure for inserting data in asp Problem with asp page returning a jpg image... Export data to Excel How to collect uncertain number of people information in a form SMTP how can i detect multiplt VBNewLine's in a row Session variable randomly mixed or lost? |
|||||||||||||||||||||||