How to fill a text box based on a % and depending on a check box.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: FPSC (notwork_at_hotmail.com)
Date: 09/22/04


Date: Wed, 22 Sep 2004 16:41:10 -0500

I have a form where the user input several numbers.
Then they need to mark a check box if they are in the state of Texas.
If that check box is filled then I need to calculate the tax for the sum of numbers from the form.

When the user click Submit, goes to a second page where he/she confirm the numbers, and submit to a third secure form to do the rest.

I was able to do part of the first form and to send the numbers to the second page.
But I could not get to the calculation on the tax depending on the check box.

Here are my codes, the bold part is what I had not been able to do:

First Page / Form:

<form method="POST" action="sendoriginal.asp">
  <input type="hidden" name="Number" value=1 size="10">
  <p><b><font size="2">Item Price: $</font><input type="text" name="cost" size="10"><font size="2">
  </font></b>
  <p><b><font size="2">Shipping: $</font><input type="text" name="ship" size="10"><font size="2">
  </font></b>
  <p style="margin-top: 0; margin-bottom: 0"><b><font size="2">Signature Confirmation (optional=$1.30): $</font><input type="text" name="sign" size="10" value="0"><font size="2">
  </font></b>
                      <p style="margin-top: 0; margin-bottom: 0">If the item
                        will be shipped to Texas click here: <font size="3">
                         <input type="checkbox" name="C1" value="ON"></font><p style="margin-top: 0; margin-bottom: 0"><b><font size="2">
                        Texas Sales Tax: $</font><input type="text" name="tax" size="10" value="0"><font size="2">
                       8.25% calculated including shipping and Insurance.</font></b><p>
                        <input type="submit" value="Submit" ><input type="reset" value="Reset" name="B2"></p>
</form>

Second Page:

<%
' 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
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("send_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(6)
 Dim arFormDBFields0(6)
 Dim arFormValues0(6)

 arFormFields0(0) = "tax"
 arFormDBFields0(0) = "tax"
 arFormValues0(0) = Request("tax")
 arFormFields0(1) = "Number"
 arFormDBFields0(1) = "Number"
 arFormValues0(1) = Request("Number")
 arFormFields0(2) = "cost"
 arFormDBFields0(2) = "cost"
 arFormValues0(2) = Request("cost")
 arFormFields0(3) = "ship"
 arFormDBFields0(3) = "ship"
 arFormValues0(3) = Request("ship")
 arFormFields0(4) = "total"
 arFormDBFields0(4) = "total"
 arFormValues0(4) = Request("total")
 arFormFields0(5) = "sign"
 arFormDBFields0(5) = "sign"
 arFormValues0(5) = Request("sign")

 FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

 If Request.ServerVariables("REMOTE_HOST") <> "" Then
  FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"), "Remote_computer_name"
 End If
 If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then
  FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"), "Browser_type"
 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

 FP_FormConfirmation "text/html; charset=windows-1252",_
      "Form Confirmation",_
      "Thank you for submitting the following information:",_
      "sendoriginal.asp",_
      "Return to the form."

End If
End If

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

%>
<%

dim n, c, s, sc, x, t

n = request ("Number")

c = request("cost")

s = request ("ship")

sc = request ("sign")

x = request ("tax")

t = (n*c)+s+sc+x

%>
  The second page form. I substitute some information for XXXXX . But this form works OK. My question is on the first part:

<form method="POST"
action="XXXXXXXXXXXXXXXXXXXXX">
<input type="hidden" name="XXXXXX" value="XXXXXX">
<input type="hidden" name="XXXXXX" value="XXXXXX">
XXXXXXXXXXXXXXXXXXXXXXXx XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX
<input type="text" name="AMOUNT" value="<%=t%>" size="20">
<input type="hidden" name="TYPE" value="S">
<input type="submit" value="Click here to go to Secure Form"> </p>
</form>

Any help will be greatly appreciated.

SC



Relevant Pages

  • Re: How to refresh page without prompt the "resend information...."?
    ... I wrote a PHP page for user input the information to search the ... And the database data will update every second. ... REQUEST to get the data from user input page. ...
    (comp.lang.php)
  • How to refresh page without prompt the "resend information...."?
    ... I wrote a PHP page for user input the information to search the ... And the database data will update every second. ... REQUEST to get the data from user input page. ...
    (comp.lang.php)
  • Re: logon script not working
    ... You host needs to turn on Parent Pathing ... | I have a logon page for a page with a form that is connected to a database. ... | FP_DumpError strErrorUrl, "Cannot create connection" ...
    (microsoft.public.frontpage.programming)
  • Re: Frontpage ASP + Form properties
    ... It was that the he file level permissions were not set correctly. ... but when I want to access to the data on my access database linked ... FP_DumpError strErrorUrl, "Cannot create connection" ... FP_DumpError strErrorUrl, "Cannot create record set" ...
    (microsoft.public.frontpage.programming)
  • Re: Frontpage ASP + Form properties
    ... "David Berry" wrote: ... records of the form it doesnt work, the database don't show any results. ... FP_DumpError strErrorUrl, "Cannot create connection" ... FP_DumpError strErrorUrl, "Cannot create record set" ...
    (microsoft.public.frontpage.programming)