Questions about Form Buttons and Submission (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Kage -> Questions about Form Buttons and Submission (11/20/2003 16:51:17)

I am designing some pretty simple forms that will save particular data to an MS Access database and I have a few questions about some things the FrontPage form wizard automatically does in relation to this.

First, I always get a confirmation page after each submission I would like to get rid of. I'm new to working with forms, this is a side project my job asked me to try and produce.

Second, the "submit" button is activated by hitting the Enter key, something that can't happen for this to work right given that the information will be pushed in via an infared scanner that sends a return, or "enter key" command after each scan which is necessary for another application.

Any suggestions on where to begin?




BeTheBall -> RE: Questions about Form Buttons and Submission (11/20/2003 17:21:22)

What would you propose in place of the confirmation page? Generally, one would want at least some sort of message to know that the records was inserted successfully. You could add some code to the confirmation page that would redirect back to the form after a couple of seconds.

As for disabling the Enter key, try the javascript here:

http://members.blue.net.au/felgall/jstip43.htm




Kage -> RE: Questions about Form Buttons and Submission (11/20/2003 17:26:49)

Unless there's an error or a problem, i basically don't want a response from it because it slows things down. This is being used on a production line of sorts. Hence the odd need to just submit and come right back. In any other situation the logic you presented is excellent and I totally agree.

Let me check that java out. Thanks you much.




BeTheBall -> RE: Questions about Form Buttons and Submission (11/20/2003 17:53:27)

OK, so right click your form, select Form Properties, then Options. You will see a place where you can place the URL of the confirmation page. Enter the page you are already on so on submit the form will simply clear itself and you are ready to enter another record. So if your form is on page.asp, page.asp will be what you will enter as the URL for the confirmation page.

By the way, welcome to the forum. [;)]




Kage -> RE: Questions about Form Buttons and Submission (11/20/2003 18:14:01)

Thanks for the welcome, I'd been reading here for a while.
I finally just decided to join cause I'm feeling impatient and would rather find someone who knows than to sit here and piddle with it for another few days lol.

Thanks for the help on the confirmation stuff, you had mentioned a java script that would auto redirect, you have a link to that too?[sm=ask.gif]




BeTheBall -> RE: Questions about Form Buttons and Submission (11/20/2003 18:35:14)

You can use javascript, but I normally use a meta tag like this:

<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.yourdomain.com/yourpage.html">

Place the code in the HEAD of the page and what it will do is redirect after 3 seconds.




Kage -> RE: Questions about Form Buttons and Submission (11/20/2003 19:37:46)

You're the man.
Thanks for the prompt and precise help. I'm new to using forms and such, it was asked of me so I'm trying to deliver and cater to those who would actually use it.

You've been a great help.[:)]




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 13:39:45)

I have another question about the confirmation page. I cannot seem to find the actual page, it seems to be some pregenerated page that frontpage comes up with automatically that i cannot find within my web. Is there a way to edit this. The name of it does appear in the SQL-type code Frontpage generates in making the database connection but nowhere does it seem to appear.. Any idea where I can go to edit it?




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 14:58:47)

You are correct in your observation. There is no confirmation page per se. FP simply generates the confirmation details following the submission of the form. You will not that when you click submit and the confirmation comes up the URL remains the same. I am not how or if that can be edited. May be one of the reasons FP offers the option of creating your own.




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 15:03:31)

Well, I made my own and it's still going to the old pregenerated one which is why I asked about it possibly being stored somewhere. I have created a confirmation page that works with the redirect you gave me but I can't get the form itself to call up the confirmation/redirect page upon submission although it is listed as:

Response.Redirect "DockToStockRecvConfirm.asp"

in the ASP part of the database procedure. The pregenerated confirmation page is no longer listed but still shows up.
Sorry for being a pain.

Kage




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 15:27:58)

Post the code for the page where your form is.




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 15:55:46)

here is all of it.

<%
' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Session.LCID = 1033
Err.Clear

strErrorUrl = ""

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("receivingNPR_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", 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(3)
Dim arFormDBFields0(3)
Dim arFormValues0(3)

arFormFields0(0) = "TrackingNumber"
arFormDBFields0(0) = "TrackingNumber"
arFormValues0(0) = Request("TrackingNumber")
arFormFields0(1) = "NPR_NPR"
arFormDBFields0(1) = "NPR_NPR"
arFormValues0(1) = Request("NPR_NPR")
arFormFields0(2) = "MasterCase"
arFormDBFields0(2) = "MasterCase"
arFormValues0(2) = Request("MasterCase")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"), "Browser_type"
End If
If Request.ServerVariables("REMOTE_HOST") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"), "Remote_computer_name"
End If
FP_SaveFieldToDB fp_rs, Now, "Timestamp"
If Request.ServerVariables("REMOTE_USER") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_USER"), "User_name"
End If

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 "DockToStockRecvConfirm.asp"

End If
End If

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

%>
<HTML>
<HEAD>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<TITLE>Dock To Stock Receiving</TITLE>
</HEAD>
<BODY>
<H1> </H1>
<H1>Dock To Stock Receiving</H1>
<HR>
<FORM METHOD="POST" ACTION="--WEBBOT-SELF--" name="Dock To Stock Receiving">
<!--webbot bot="SaveDatabase" suggestedext="asp" u-asp-include-url="../_fpclass/fpdbform.inc" s-dataconnection="receivingNPR" s-recordsource="Results" u-database-url="../fpdb/receivingNPR.mdb" u-confirmation-url="DockToStockRecvConfirm.asp" s-builtin-fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER" s-builtin-dbfields="Browser_type Remote_computer_name Timestamp User_name" s-form-fields="TrackingNumber NPR_NPR MasterCase" s-form-dbfields="TrackingNumber NPR_NPR MasterCase" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="34604" --><OL>
<LI>
<P>
Master Case:</P>
<P>
<INPUT TYPE=TEXT NAME="MasterCase" SIZE=20 MAXLENGTH=20>
<BR>
</P>
<LI>
<P>
Tracking Number:</P>
<P>
<INPUT TYPE=TEXT NAME="TrackingNumber" SIZE=50 MAXLENGTH=50>
<BR>
</P>
<LI>
<P>
NPR:</P>
<P>
<INPUT TYPE=CHECKBOX NAME="NPR_NPR" value="ON"> NPR<BR>
</P>
</OL>
<INPUT TYPE=SUBMIT VALUE="Submit Form">
<INPUT TYPE=RESET VALUE="Reset Form">
</FORM>
<HR>
Revised:
<!--WEBBOT BOT=TimeStamp
S-Type="EDITED"
S-Format="%m/%d/%y"
--></H5>
</BODY>
</HTML>




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 16:08:24)

Delete this line at the top:

' FP_ASP ASP Automatically generated by a Frontpage Component. Do not Edit.

And then after the red code, delete this gray code:

<!--webbot bot="SaveDatabase" suggestedext="asp" u-asp-include-url="../_fpclass/fpdbform.inc" s-dataconnection="receivingNPR" s-recordsource="Results" u-database-url="../fpdb/receivingNPR.mdb" u-confirmation-url="DockToStockRecvConfirm.asp" s-builtin-fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER" s-builtin-dbfields="Browser_type Remote_computer_name Timestamp User_name" s-form-fields="TrackingNumber NPR_NPR MasterCase" s-form-dbfields="TrackingNumber NPR_NPR MasterCase" startspan -->

And this:

<!--webbot bot="SaveDatabase" endspan i-checksum="34604" -->

Do NOT delete this:

<!--#include file="../_fpclass/fpdbform.inc"-->

Save the page and try it again.

You may want to save a backup copy before you do the deleting. [;)]




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 16:25:15)

<!--#include file="../_fpclass/fpdbform.inc"-->

is in the gray text you are telling me to delete. do i need to leave it in the webbot or do i need to make two seperate lines for that?




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 16:27:56)

Simply change this:

<!--#include file="../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan i-checksum="34604" -->

to only this:

<!--#include file="../_fpclass/fpdbform.inc"-->




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 16:33:55)

it still submits but it gives me the old confirmation page lol.

i take it that the webbot was part of the un-needed jibberish frontpage generates that some hardcore html coders are so against?




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 17:27:02)

You are correct about the webbot stuff. It is not traditional HTML coding and would annoy coders. Here is one last thing you can try:

Find this:

ACTION="--WEBBOT-SELF--"

and replace --WEBBOT-SELF-- with the name of your page (the page on which the form is, not the page you are redirecting to.) So it will look something like this:

ACTION="mypage.asp"




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 17:33:05)

do you think it would help if I rebuilt the form itself (i built it months ago) and added the confirmation page in first thing?




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 17:56:20)

That did it, I rebuilt it and it went to the right page.

Thanks for all your help once again. if you're ever in dfw, i'll buy you a beer.

[:)]




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 17:58:49)

Wouldn't hurt. I would then name it slightly different or rename the original page and see where the differences are. I have no idea how it is still referring you to FP's confirmation page as the code to do so no longer exists on your page. Don't be insulted, but are you sure the page you are updating is the same page you are testing? I have done that before. Spent hours editing a page to try and get it to work and then realized that when I tested I was testing a completely different page! Anyway, there should be no harm done in just re-creating the page. Good luck.




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 18:03:21)

Glad it worked. I assume dfw is Dallas/Fort Worth? I am a big Dolphins fan so I will be watching Thursday's football game with a great deal of interest. If I am ever there, I'll take you up on your offer, although I am afraid Coca-Cola is about as hard as it gets for me. Afterall, I am from Utah! [:D]




Kage -> RE: Questions about Form Buttons and Submission (11/24/2003 19:21:18)

HAHA!

I didn't notice the Utah thing, that's pretty funny. Rum and coke then [;)] (j/k)


I was trying out this Java script to prevent the Enter key and it seems to work anywhere but within the text box itself. Not sure where I went wrong with that, after all i just copied and pasted lol. Have you done much with forms, you seem to know an awful lot off the top of your head.




BeTheBall -> RE: Questions about Form Buttons and Submission (11/24/2003 20:29:10)

You probably didn't include the <script> tags. Simply place this right above this tag </head> near the top of the page.

<Script Language="javascript">
function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
</script>

I tried it on one of my pages and it seems to work.




Kage -> RE: Questions about Form Buttons and Submission (11/25/2003 19:40:39)

LMFAO

i was testing the wrong damn page hhahahahaha.

sorry dude.

is there a way to make web pages automatically adjust to screen resoultion at all?




BeTheBall -> RE: Questions about Form Buttons and Submission (11/25/2003 20:50:25)

Most of my pages are in templates and the template is usually based on a table. When a table is set to 100% width, it will fill the page regardless of the resolution used. So I guess the short answer is "yes". Is that what you mean?




Kage -> RE: Questions about Form Buttons and Submission (11/26/2003 15:15:51)

Yes, that's what I meant, that was just an offhand qestion but told me what I needed.

I got the java to work somehow, oddly enough it just kind of started working without me changing anthing but retyping exactly what I had. Either way it started up.

Another question though is about these damn webbots. I've got one form that has three comment boxes for certain data. The first of which is required data. The other two are not, however, I get an error message that says the data is required. This form was built by hand by someone else, I'm just making changes. The webbot itself says:

<!--webbot bot="Validation" b-value-required="True" -->

If I change the webot to False it errors out on the ODBC connection saying it can't be null which I have this code to take care of it:

' ' ' ' if Notes has data then add Notes
' ' ' ' to sql statement
IF strNotes <> "" THEN
SQL1 = SQL1 & ", Notes"
SQL2 = SQL2 & ", '" & strNotes & "'"
END IF


But it still requires data either way. Any suggestions about the webbot. I took it out complete and it basically just stopped working complete.




BeTheBall -> RE: Questions about Form Buttons and Submission (11/29/2003 19:55:25)

If you want, send me the entire page via email and I will have a look. The webbot is not the whole piece of the puzzle when it comes to form field validation. Earlier in the page will be some javascript that is doing the actual validating.




Kage -> RE: Questions about Form Buttons and Submission (12/1/2003 11:22:17)

That's awfully generous of you.
The whole setup is actually three pages, this one was hand coded and is not front page driven, but I didn't write the code for this one, i'm just trying to modify it to get what I need out of it.
I'll send it if you want to look, it contains some SQL, java and html.
I appreciate your help. If you can't figure it out or don't have time to mess with this I fully understand.

kage




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.09375