Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 14th, 2010, 11:52 AM
Registered User
 
Join Date: Apr 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re-Calculating my Remaining Balance Total on an Edit Page

I have the following code:

<%@ Language=VBScript %>

<%Response.Expires = -1 %>
<%Response.ExpiresAbsolute = Now() - 1 %>
<%Response.AddHeader "pragma", "no-cache" %>
<%Response.AddHeader "cache-control", "private" %>
<%Response.CacheControl = "no-cache" %>

<%
Response.Expires = -1000
Response.Buffer = True
Response.Clear
%>
<%
Your_Username = Request.Cookies("Username")
%>
<!--#include file="Hallman-Logincheck.asp"-->

<html>
<head>
<!--
The Hallman Family Edit Registration Page
Author: Angela Hicks
Date: 2/12/2010

Filename: Hallman-EditRegistration.htm
Supporting files: back.jpg, left.jpg, vhouse1.jpg, main.css
right.jpg, rforms.css
-->

<title>Your Registration Information: <% Response.Write(Your_Username) %></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="Generator" content="Microsoft ExpressWeb 2.0">
<meta name="description" content="Your source of information for Hallman Family, photos, and news!">
<meta name="keywords" content="Hallman, hallman, Hallman Family, hallman family, Hallman Family Vacation, hallman family vacation, Family Vacation, family vacation">
<meta name="robots" content="All">
<meta name="rating" content="General">
<meta name="distribution" content="Members">
<meta name="classification" content="Recreation">
<meta name="copyright" content="Angela M Hicks">
<meta name="author" content="Angela M Hicks">
<link rel="stylesheet" type="text/css" href="data/css.css">
<link href="styles/main.css" rel="stylesheet" type="text/css">
<link href="styles/rforms.css" rel="stylesheet" type="text/css">

<style type="text/css">
#pymt {
width: 98px;
}
</style>

</head>

<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.open (Server.mappath("db/db.mdb"))
Set rs = Server.CreateObject("ADODB.Recordset")

sql="SELECT * FROM Hallman"
sql=sql & " WHERE zUsername = '" & Request.Cookies("Username") & "' "

' Execute SQL statement
rs.open sql, conn

while not rs.eof

If Request.Cookies("Username") = rs("zUsername") Then

Response.Write "<body OnLoad=' & chr(34) & 'document.EditRegistration.zfName.focus();' & chr(34) & '>" &_
"<div id='head'><img src='images/vhouse1.jpg' alt='Vacation Home' height='150' width='830'>" &_
"</div>" &_
"<div id='links'>" &_
"<ul>" &_
"<li><a href='Hallman-Home.asp'>home</a></li>" &_
"<li><a href='photo_gallery/photo_gallery.htm'>photo gallery</a></li>" &_
"<li><a href='event/event.htm'>events</a></li>" &_
"<li><a href='menu/menu.htm'>menu</a></li>" &_
"<li><a href='news/news.htm'>news</a></li>" &_
"<li><a href='direction/direction.htm'>driving direction</a></li>" &_
"<li><a href='http://www.weather.com/weather/today/USFL0372?lswe=Orlando,%20FL,%20United%20States&fro m=searchbox_typeahead'>weather</a></li>" &_
"<li><a href='Hallman-Logout.asp'>logout</a></li>" &_
"<li><a href='contact/contact.htm'>contact info</a></li>" &_
"</ul>" &_
"</div>" &_
"<div id='mainContent'>" &_
"<div id='leftColumn'>" &_
"</div>" &_
"<div id='rightColumn'>" &_
"<br />" &_
"<br />" &_
"<br />" &_
"<h1>User Information</h1>" &_
"<p><span>*</span>indicates required information</p>" &_
"<form name='editregistration' id='editregistration' action='Hallman-EditUpdate.asp' method='post'>" &_
"<input type='hidden' name='eMail' id='eMail' value='[email protected]'>" &_
"<fieldset id='contactFields'>" &_
"<legend>Contact Information</legend>" &_
"<label class='blockLabel'>" &_
"First Name<span>*</span>" &_
"<input type='text' id='fName' name='zfName' value='" & rs.Fields("zfName") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Last Name<span>*</span>" &_
"<input type='text' id='lName' name='zlName' value='" & rs.Fields("zlName") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Street Address<span>*</span>" &_
"<input type='text' id='address' name='zAddress' value='" & rs.Fields("zAddress") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"City<span>*</span>" &_
"<input type='text' id='city' name='zCity' value='" & rs.Fields("zCity") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"State<span>*</span>" &_
"<input type='text' id='state' name='zState' maxlength='2' value='" & rs.Fields("zState") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Zip<span>*</span>" &_
"<input type='text' id='zip' name='zZip' maxlength='10' value='" & rs.Fields("zZip") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Phone<span>*</span>" &_
"<input type='text' id='phone' name='zPhone' value='" & rs.Fields("zPhone") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Email<span>*</span>" &_
"<input type='text' id='email' name='zEmail' value='" & rs.Fields("zEmail") & "'>" &_
"</label>" &_
"<label class='blockLabel'>" &_
"Today's Date<span>*</span>" &_
"<input type='text' id='date' name='zDate' value='" & rs.Fields("zDate") & "'>" &_
"</label>" &_
"</fieldset>" &_
"<fieldset id='registrationInfo'>" &_
"<legend>Registration Information</legend>" &_
"<fieldset id='payment'>" &_
"<legend>Cost Information</legend>" &_
"<label class='blockLabel'>" &_
"Are you making one lump sum payment of 543.10?" &_
"<select id='payment' name='zFpymt' style='width: 50px' value='" & rs.Fields("zFpymt") & "'>" &_
"<option selected value='" & rs.Fields("zFpymt") & "'>" & rs.Fields("zFpymt") & "</option>" &_
"<option value='yes'>Yes</option>" &_
"<option value='no'>No</option>" &_
"</select>" &_
"</label>" &_
"<label for='prevNo'>Tentative Pymt Date</label>" &_
"<input type='text' id='pDate' name='zpDate' style='width: 70px' value='" & rs.Fields("zpDate") & "'>" &_
"<label class='blockLabel'>5 Month Payment Plan of $108.62 monthly</label>" &_
"<strong>" &_
"<center style='color: #ffffff'>Please key in the amount of each payment as you send monthly</center>" &_
"</strong>" &_

"<table cellpadding='6' cellspacing='6' style='text-align: center' align='center'>" &_
"<tr>" &_
"<td style='font-family: Verdana; color: #000000; font-size: 12px'>" &_
"1st Payment</td>" &_
"<td style='color: #000000; font-size: 12px'>Feb 22,2010</td>" &_
"<td style='color: #000000; font-size: 12px'>" &_
"<input type='text' name='zPymt1' size='7' style='width: 80px' value='" & rs.Fields("zPymt1") & "'>" &_
"</td>" &_
"</tr>" &_
"<tr>" &_
"<td style='color: #000000; font-size: 12px'>2nd Payment</td>" &_
"<td style='color: #000000; font-size: 12px'>Mar 15, 2010</td>" &_
"<td><input type='text' name='zPymt2' size='7' style='width: 80px' value='" & rs.Fields("zPymt2") & "'>" &_
"</td>" &_
"</tr>" &_
"<tr>" &_
"<td style='color: #000000; font-size: 12px'>3rd Payment</td>" &_
"<td style='color: #000000; font-size: 12px'>Apr 15, 2010</td>" &_
"<td><input type='text' name='zPymt3' size='7' style='width: 80px' value='" & rs.Fields("zPymt3") & "'>" &_
"</td>" &_
"</tr>" &_
"<tr>" &_
"<td style='color: #000000; font-size: 12px'>4th Payment</td>" &_
"<td style='color: #000000; font-size: 12px'>May 15, 2010</td>" &_
"<td><input type='text' name='zPymt4' size='7' style='width: 80px' value='" & rs.Fields("zPymt4") & "'>" &_
"</td>" &_
"</tr>" &_
"<tr>" &_
"<td style='color: #000000; font-size: 12px'>5th Payment</td>" &_
"<td style='color: #000000; font-size: 12px'>Jun 15, 2010</td>" &_
"<td><input type='text' name='zPymt5' size='7' style='width: 80px' value='" & rs.Fields("zPymt5") & "'>" &_
"</td>" &_
"</tr>" &_
"<tr>" &_
"<td style='color: #000000; font-size: 12px'></td>" &_
"<td style='color: #000000; font-size: 12px'>Remaining Balance</td>" &_
"<td><input type='text' name='zTotal' size='10' value='" & rs.Fields("zTotal") & "'>" &_
"</td>" &_
"</tr>" &_
"</table>" &_
"<input align='right' type='button' value='Calculate your total' name='btnCalculate' onClick='calcTotal()' style='width: 135px'>" &_
"<input align='right' type='reset' value='Clear' name='btnClear'>" &_
"<br>" &_
"</fieldset>" &_
"<label for='comments' class='blockLabel'>Comments</label>" &_
"<textarea id='comment' name='zComment' rows='5' cols='55'>" & rs.Fields("zComment") & "</textarea>" &_
"</fieldset>" &_
"</fieldset>" &_
"<br />" &_
"<input type='submit' name='action' value='Save'>" &_
"<input type='submit' name='action' value='Delete'>" &_
"<input type='button' value='Print' onClick='window.print()'>" &_
"</form>" &_
"<script language='javascript' type='text/javascript'>" &_
"function isValid1(){" &_
"var themessage = 'You are required to complete the following fields: ';" &_
"if (document.Registrationform.zfName.value=='') {" &_
"themessage = themessage + ' - First Name';" &_
"}" &_
"if (document.Registrationform.zlName.value=='') {" &_
"themessage = themessage + ' - Last Name';" &_
"}" &_
"if (document.Registrationform.zAddress.value=='') {" &_
"themessage = themessage + ' - Street Address';" &_
"}" &_
"if (document.Registrationform.zCity.value=='') {" &_
"themessage = themessage + ' - City';" &_
"}" &_
"if (document.Registrationform.zZip.value=='') {" &_
"themessage = themessage + ' - Zip';" &_
"}" &_
"if (document.Registrationform.zPhone.value=='') {" &_
"themessage = themessage + ' - Phone';" &_
"}" &_
"if (document.Registrationform.zEmail.value=='') {" &_
"themessage = themessage + ' - E-mail';" &_
"}" &_
"if (document.Registrationform.zDate.value=='') {" &_
"themessage = themessage + ' - Date';" &_
"}" &_
"if (document.Registrationform.zUsername.value=='') {" &_
"themessage = themessage + ' - Username';" &_
"}" &_
"if (document.Registrationform.zPassword.value=='') {" &_
"themessage = themessage + ' - Password';" &_
"}" &_
"if (document.Registrationform.zAnswer.value=='') {" &_
"themessage = themessage + ' - Answer';" &_
"}" &_
"//alert if fields are empty and cancel form submit" &_
"if (themessage == 'You are required to complete the following fields: ') {" &_
"document.Registrationform.submit();" &_
"}" &_
"else {" &_
"alert(themessage);" &_
"return false;" &_
"}" &_
"function calcTotal()" &_
"{" &_
"var strPymt1, strPymt2, strPymt3, strPymt4, strPymt5, strTPymt, strTotal;" &_
"strPymt1=parseFloat(document.EditRegistrationForm .zPymt1.value);" &_
"strPymt2=parseFloat(document.EditRegistrationForm .zPymt2.value);" &_
"strPymt3=parseFloat(document.EditRegistrationForm .zPymt3.value);" &_
"strPymt4=parseFloat(document.EditRegistrationForm .zPymt4.value);" &_
"strPymt5=parseFloat(document.EditRegistrationForm .zPymt5.value);" &_
"strTPymt=(543.10 - strPymt1 - strPymt2 - strPymt3 - strPymt4 - strPymt5);" &_
"strTotal= (strTPymt);" &_
"document.EditRegistrationForm.zTotal.value=(strTo tal);" &_
"window.alert('Your New Remaining Balance is ' + strTotal)" &_
"}" &_
"</script>" &_
"</div>" &_
"</body>" &_
"</html>"
End If

rs.MoveNext
Wend

rs.close
set rs=nothing
conn.close
set conn=nothing
%>

I'm getting the following error:

The Calculation button do work

Line:61
Char: 1899
Error: Expected '}'
Code: 0
URL: http://www.amhicks.ent/Hallman/hallm...gistration.asp

Line:61
Char: 2
Error: Syntax error
Code: 0
URL: http://www.amhicks.ent/Hallman/hallm...gistration.asp

Can anyone tell me what is wrong?

Thanks in advance!!!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Subtotals and Totals in asp page bootsy Classic ASP Basics 3 May 13th, 2008 09:33 AM
Problem in calculating total sales in MDX query jaee SQL Server 2000 0 March 9th, 2007 11:10 AM
calculating grand total blkskullwork Javascript 2 December 18th, 2006 10:36 AM
Calculating total form! require assistance Neeko Java Basics 1 May 4th, 2006 06:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.