Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How can I return information to a form if some info wasn't given? Posted by HGeneAnthony on 27 Nov 2002 at 9:01 AM
I want to submit the page to the same page and add a new record, based on the info given, to my database. If some info isn't given I'd like to return the info to the initial textboxes. Is there a way I can check whether the information was returned when I first load the page. You see I'm using Netscape 7.0 and when I initially load the page I get a confirm messagebox telling me, "the page you are trying to view contains post data. If you resend the data, any action on the form carried out will be repeated. To resend the data, click OK." I don't want this message to appear to any user because it could confuse them. Currently I'm using:

<%
custName=TRIM(Request.Form("txtName"))
%>
<input name="txtName" type="text" id="txtName" value="<%=Server.HTMLEncode(custName)%>">

How can I rewrite this to avoid that error?
Report
Re: How can I return information to a form if some info wasn't given? Posted by gigsvoo on 30 Nov 2002 at 12:46 AM
Use a boolean flag. If variable is TRUE then it is a submitting. If flag is FALSE skip the insert/update portion and display form just like it is.


Neo Gigs
http://communities.msn.com.my/VisualBasicwithNeo

Report
Re: How can I return information to a form if some info wasn't given? Posted by alireza on 1 Dec 2002 at 12:50 AM
: I want to submit the page to the same page and add a new record, based on the info given, to my database. If some info isn't given I'd like to return the info to the initial textboxes. Is there a way I can check whether the information was returned when I first load the page. You see I'm using Netscape 7.0 and when I initially load the page I get a confirm messagebox telling me, "the page you are trying to view contains post data. If you resend the data, any action on the form carried out will be repeated. To resend the data, click OK." I don't want this message to appear to any user because it could confuse them. Currently I'm using:
:
: <%
: custName=TRIM(Request.Form("txtName"))
: %>
: <input name="txtName" type="text" id="txtName" value="<%=Server.HTMLEncode(custName)%>">
:
: How can I rewrite this to avoid that error?
:

Report
Re: How can I return information to a form if some info wasn't given? Posted by dweeb on 9 Jan 2003 at 4:38 PM
Here's the validation script I've used in the past when required fields have not been populated.

<SCRIPT LANGUAGE="VBScript" EVENT="OnClick" FOR="GetRecs">
--->>>in the previous line, 'GetRecs' is the name of the button used to submit the form. DO NOT use a submit type input for this script. use a button instead.

Dim TheForm
Set TheForm = Document.filter
--->>>set TheForm = Document.<<insert your form name here>>
If IsDate(TheForm.Bdate.Value) = false then
MsgBox "Invalid Begin Date Format."
ElseIf IsDate(TheForm.Edate.Value) = false then
MsgBox "Invalid End Date Format."
--->>>the four previous lines do validation checking for a proper date format for two fields on my form. If you want to check for nulls, just change to 'If TheForm.<<field>>.Value = "" then MsgBox "You must fill in the <<field>> field.
else
TheForm.Submit
end if
</script>

Key is to remember to change your submit type input to a button, and reference your button name in the script tag for the FOR value.

Cheers.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.