Submit upon Confirmation.

Results 1 to 3 of 3

Thread: Submit upon Confirmation.

  1. #1
    Marie Guest

    Default Submit upon Confirmation.

    A Confirmation page (Confirm.asp) will show the data retrieved from a form in the Submitting Page (Submit.asp). <BR><BR>In the confirm.asp, Upon clicking the Button "Confirm", it will then insert the data into the access dbase, else it&#039ll just display the data get from submit.asp.<BR>However, opening of confirm.asp, it will directly insert the data into dbase, which is not wat I want.<BR><BR>Following is my confirm.asp :<BR> <BR>Name : &#060;% =Request("SName") &#037;&#062; <BR>Student Number : &#060;% =Request("SNum") &#037;&#062;<BR><BR>&#060;Input Type= "Submit" Value="Confirm" Name="Confirm"><BR><BR>&#060;Script Language ="VBScript"><BR>Sub Confirm_Onclick<BR>&#060;%<BR> Set DataConn = Server.CreateObject("ADODB.Connection")<BR> DataConn.Open "maindb"<BR> SQLQUERY= "Insert Into Students ...........Statements............."<BR> Set Students = DataConn.Execute(SQLQUERY)<BR> DataConn.Close<BR>&#037;&#062;<BR>End Sub<BR>&#060;/Script><BR><BR><BR><BR>Confirm_Onclick

  2. #2
    Join Date
    Dec 1969
    Posts
    35

    Default RE: Submit upon Confirmation.

    Okay here&#039s the problem with the script that you wrote. When an ASP page is compiled by the server and then transmitted to the browser, the ASP script code is processed by the server then the HTML is passed to the browser for posting to the web browser. So what&#039s happening here is that the server sees the database submission section, before it posts the page.<BR>The solution to this is simple. Set up the page like this:<BR>&#060;%if Request.Form("confirm") = 1 then<BR> &#039do all of the database entry<BR> else<BR> &#039write all of the code that confirms the data entered by<BR> &#039the user<BR>&#037;&#062;<BR>[all of the rest of you code goes here]<BR><BR><BR>[at the bottom of the page]<BR>&#060;input type=hidden name="confirm" value="undefined"><BR>&#060;script language=vbscript><BR>sub Submit_onClick<BR> window.document.form[0].confirm.value=1<BR> window.document.form[0].action="confirm.asp"<BR> window.document.form[0].method="post"<BR> window.document.form[0].submit<BR>end sub<BR>&#060;/script><BR><BR>I hope this works for you. Happy Programming =)

  3. #3
    Marie Guest

    Default RE: Submit upon Confirmation.

    I did it in the following way, everything is going fine, except the database insertion area. <BR><BR>An error occured that Field &#039Students.Cat can&#039t be a zero string&#039<BR><BR>&#060;%if Request("Confirm") = "1" Then &#037;&#062;<BR>&#060;% <BR>Set DataConn = Server.CreateObject("ADODB.Connection")<BR>DataCon n.Open "maindb"<BR>SQLQuery = "INSERT INTO Students (Cat, SNum, SName) " & _<BR> "VALUES(&#039"& Request("Cat") &"&#039, &#039"& Request("SNum") &"&#039, &#039" & _ <BR> Request("SName") &"&#039 )"<BR>Set Students = DataConn.Execute(SQLQuery)<BR>Dataconn.Close<BR>&# 037;&#062;<BR><BR>&#060;%Else &#037;&#062;<BR><BR>&#060;Form Name= "Form"><BR>Name= &#060;%=request("SName")&#037;&#062; <BR><BR>Name1= &#060;%=request("SNum")&#037;&#062; <BR><BR>Name3= &#060;%=request("Cat")&#037;&#062; <BR><BR><BR>&#060;Input Type= "Submit" Value="Confirm" Name= "Submit"><BR>&#060;Input Type= "hidden" Value="undefined" Name="confirm"><BR>&#060;script language=vbscript><BR>sub Submit_onClick<BR> window.document.form.confirm.value="1"<BR> window.document.form.action="confirm.asp"<BR> window.document.form.method="post"<BR> end sub<BR>&#060;/script><BR>&#060;/form> <BR><BR>&#060;%End If&#037;&#062; <BR>

Posting Permissions

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