OK...I've spent some time researching, but have not found a simple
answer...so I'm going to copy my code here and see if someone can help me.
This code is for a page on which a user is entering soccer stats (games
played, goals scored, shots at goal, assists, goals allowed, saves, and
shutouts). Then I'd like to calculate goal percentage (= goals / shots at
goal) and save percentage (= saves / (saves + goals allowed). I'd like all
of these results (those entered AND calculated) to be placed into a database
table.
I do not yet have the "Goal Percentage" and "Save Percentage" fields created
in the database. I can do that easily, but I figured I'd ask for help here
before I took the next steps.
Currently my form connects to the database, and all of the entered fields
will be saved into the database fields. I just need to know how to get the
form to perform and store the calculations. Can you help?
Code is below...(If there's an easier or better way for me to provide the
code, let me know...Thanks!)
-- Nate
-------------------
<%
' 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 = "stat_submission_form_soccer_boys.asp"
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("stat_submission_form_soccer_boys_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(12)
Dim arFormDBFields0(12)
Dim arFormValues0(12)
arFormFields0(0) = "Games_Played"
arFormDBFields0(0) = "Games_Played"
arFormValues0(0) = Request("Games_Played")
arFormFields0(1) = "First_Name"
arFormDBFields0(1) = "First_Name"
arFormValues0(1) = Request("First_Name")
arFormFields0(2) = "School"
arFormDBFields0(2) = "School"
arFormValues0(2) = Request("School")
arFormFields0(3) = "Shots_At_Goal"
arFormDBFields0(3) = "Shots_At_Goal"
arFormValues0(3) = Request("Shots_At_Goal")
arFormFields0(4) = "Assists"
arFormDBFields0(4) = "Assists"
arFormValues0(4) = Request("Assists")
arFormFields0(5) = "Shutouts"
arFormDBFields0(5) = "Shutouts"
arFormValues0(5) = Request("Shutouts")
arFormFields0(6) = "Grade"
arFormDBFields0(6) = "Grade"
arFormValues0(6) = Request("Grade")
arFormFields0(7) = "Last_Name"
arFormDBFields0(7) = "Last_Name"
arFormValues0(7) = Request("Last_Name")
arFormFields0(8) = "Goals_Scored"
arFormDBFields0(8) = "Goals_Scored"
arFormValues0(8) = Request("Goals_Scored")
arFormFields0(9) = "HS_Enrollment"
arFormDBFields0(9) = "HS_Enrollment"
arFormValues0(9) = Request("HS_Enrollment")
arFormFields0(10) = "Goals_Allowed"
arFormDBFields0(10) = "Goals_Allowed"
arFormValues0(10) = Request("Goals_Allowed")
arFormFields0(11) = "Saves"
arFormDBFields0(11) = "Saves"
arFormValues0(11) = Request("Saves")
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
Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "stat_submission_form_soccer_boys.asp"
End If
End If
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
%>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>NCSAA - Stat Submission Form - Boys' Soccer</title>
<meta name="Microsoft Theme" content="ncsaa-expedition 0011, default">
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse; border-style: solid; border-width: 0" width="100%">
<tr>
<td width="100%" align="center" style="border-style: solid;
border-width: 0; padding-left: 4; padding-right: 4; padding-top: 1;
padding-bottom: 1">
<p align="center" style="margin-top: 0; margin-bottom: 0">
<img border="1" src="NCSAA_Logo_New.jpg" width="143" height="83">
<map name="FPMap2">
<area href="ncsaa_home.htm" shape="rect" coords="4, 0, 47, 59">
<area href="mission.htm" shape="rect" coords="51, 0, 104, 59">
<area href="schools.htm" shape="rect" coords="110, 1, 162, 59">
<area href="publications.htm" shape="rect" coords="233, 0, 309, 59">
<area href="events.htm" shape="rect" coords="313, 0, 361, 59">
<area href="news.htm" shape="rect" coords="366, 0, 408, 59">
<area href="support.htm" shape="rect" coords="412, 0, 467, 59">
<area href="advertising.htm" shape="rect" coords="471, 0, 545, 59">
<area href="information.htm" shape="rect" coords="551, 0, 626, 59">
<area href="contact.htm" shape="rect" coords="631, 0, 687, 59">
<area href="services.htm" shape="rect" coords="162, 5, 228, 52">
</map>
<img border="0" src="Home%20Page%20Menu%20Banner%20SERVICES%20copy.gif"
usemap="#FPMap2" width="688" height="60"></td>
</tr>
</table>
<p align="center" style="margin-top: 0; margin-bottom: 0">
</p>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:
collapse; border-style: solid; border-width: 0; padding-left: 4;
padding-right: 4; padding-top: 1; padding-bottom: 1" width="97%"
bgcolor="#0000CC" height="30">
<tr>
<td width="14%" align="center" style="border:1px solid #000000; "
height="28">
<p style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a style="color: #FFFFFF; font-weight: bold; text-decoration: none"
href="coaches_services.htm">
Coaches'</a></b></font><p style="margin-top: 0; margin-bottom:
0"><font color="#FFFFFF"><b>
<a style="color: #FFFFFF; font-weight: bold; text-decoration: none"
href="coaches_services.htm">
Services</a></b></font></td>
<td width="14%" align="center" height="30" style="border:1px solid
#000000; " bordercolorlight="#000000" bordercolordark="#000000">
<p style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="equipment_program.htm" style="text-decoration: none">
<font color="#FFFFFF">Equipment</font></a></b></font><p
style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="equipment_program.htm" style="text-decoration: none">
<font color="#FFFFFF">Program</font></a></b></font></td>
<td width="14%" align="center" height="30" style="border: 1px solid
#000000">
<p style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="community_programs.htm" style="text-decoration: none">
<font color="#FFFFFF">Community</font></a></b></font><p
style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="community_programs.htm" style="text-decoration: none">
<font color="#FFFFFF">Programs</font></a></b></font></td>
<td width="14%" align="center" height="30" style="border: 1px solid
#000000"><font color="#FFFFFF"><b>
<a style="text-decoration: none" href="speakers_bureau.asp">
<font color="#FFFFFF">Speakers' Bureau</font></a></b></font></td>
<td width="15%" align="center" height="30" style="border: 1px solid
#000000">
<font color="#FFFFFF"><b>
<a href="awards.htm" style="text-decoration: none"><font
color="#FFFFFF">
Awards</font></a></b></font></td>
<td width="15%" align="center" height="30" style="border: 1px solid
#000000; ">
<font color="#FFFFFF"><b>
<a href="recruiting_service.htm" style="text-decoration: none">
<font color="#FFFFFF">Recruiting Service</font></a></b></font></td>
<td width="15%" align="center" height="30" style="border: 4px solid
#000000; ">
<p style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="stat_ranking_service.htm" style="text-decoration: none">
<font color="#FFFFFF">Stat Ranking</font></a></b></font></p>
<p style="margin-top: 0; margin-bottom: 0"><font color="#FFFFFF"><b>
<a href="stat_ranking_service.htm" style="text-decoration: none">
<font color="#FFFFFF">Service</font></a></b></font></td>
</tr>
</table></center>
</div>
<p align="center" style="margin-top: 0; margin-bottom: 0">
</p>
<table border="10" cellpadding="5" cellspacing="0" style="border-collapse:
collapse" width="100%" id="table4">
<tr>
<td width="100%" bordercolorlight="#FF0000" bordercolordark="#024EFD"
style="border-right-color: #800000; border-bottom-color: #800000">
<p align="center" style="margin-top: 0; margin-bottom: 0"><font
face="Berlin Sans FB" size="6" color="#024EFD">
NCSAA Stat Submission Form - BOYS' SOCCER</font></p>
<p align="center" style="margin-top: 0; margin-bottom: 0">(<b>Please
submit only
high school varsity team statistics. Also, do not submit stats for an
indoor soccer season.</b>)</p>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="right" style="margin-top: 0; margin-bottom: 0">
<font size="2">
<a href="stat_submission_forms.htm">Back to Stat Submission Forms for All
Sports</a></font></p>
<p align="left" style="margin-top: 0; margin-bottom: 0"><b>Instructions
for
submitting stats:</b></p>
<p align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="justify" style="margin-top: 0; margin-bottom: 0"><b>1)
</b>Please
submit stats ONLY for players on your <i><b>high school varsity</b></i>
boys' soccer team.</p>
<p align="justify" style="margin-top: 0; margin-bottom: 0"><b>2)
</b>Please
complete the following form completely to submit stats for one player.
Press "Submit" after you are finished completing the form.</p>
<p align="justify" style="margin-top: 0; margin-bottom: 0"><b>3)
</b>After
submitting.the form, you will be returned to this form to submit stats for
another player. Repeat for as many players as you wish..</p>
<p align="justify" style="margin-top: 0; margin-bottom: 0"><b>4) </b>We
will compile the stats and
update the <a href="stat_leaders_board.htm">Stat Leaders Board</a>.
Thanks for participating!</p>
<p align="justify" style="margin-top: 0; margin-bottom: 0"><b>5) </b>Any
errors or problems can be reported to 724-846-2764 or
<a href="mailto:
[email protected]">
[email protected]</a>. Feel free
to call with questions, problems, or suggestions.</p>
<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>
<form method="POST" name="FrontPage_Form1" action="--WEBBOT-SELF--"
onSubmit="" language="JavaScript">
<!--webbot bot="SaveDatabase" s-builtin-fields="REMOTE_HOST
HTTP_USER_AGENT Timestamp REMOTE_USER" s-form-fields="Games_Played First_Name
School Shots_At_Goal Assists Shutouts Grade Last_Name Goals_Scored
HS_Enrollment Goals_Allowed Saves"
u-confirmation-url="stat_submission_form_soccer_boys.asp" startspan
SuggestedExt="asp" S-DataConnection="stat_submission_form_soccer_boys"
S-RecordSource="Results"
U-Database-URL="fpdb/stat_submission_form_soccer_boys.mdb"
U-Validation-Error-Url="stat_submission_form_soccer_boys.asp"
S-Builtin-DBFields="Remote_computer_name Browser_type Timestamp User_name"
S-Form-DBFields="Games_Played First_Name School Shots_At_Goal Assists
Shutouts Grade Last_Name Goals_Scored HS_Enrollment Goals_Allowed Saves"
U-ASP-Include-Url="_fpclass/fpdbform.inc" --><input TYPE="hidden"
NAME="VTI-GROUP" VALUE="0"><!--#include
file="_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan
i-checksum="40548" --><p align="left" style="margin-top: 0; margin-bottom: 0">
Name of School:
<!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" -->
<select size="1" name="School" tabindex="1">
<option>Select school.</option>
<option>Beaver County Christian (Beaver Falls, PA)</option>
<option>Betesda Christian (Opa-Locka, FL)</option>
<option>Blackhawk Christian (Fort Wayne, IN)</option>
<option>Briarcrest Christian (Memphis, TN)</option>
<option>Calvary Baptist (Hurricane, WV)</option>
<option>Cambridge Christian (Cambridge, MN)</option>
<option>Cape Christian (Cape May Court House, NJ)</option>
<option>Cascade Christian (Jacksonville, OR)</option>
<option>Champion Christian (Chico, CA)</option>
<option>Charlotte Christian (Charlotte, NC)</option>
<option>Cheswick Christian (Cheswick, PA)</option>
<option>Clinton Christian (Upper Marlboro, MD)</option>
<option>Colorado Springs Christian (Colorado Springs, CO)</option>
<option>Coral Springs Christian (Coral Springs, FL)</option>
<option>Covenant Christian (Dandridge, TN)</option>
<option>Covenant Christian (Indianapolis, IN)</option>
<option>Eden Christian (Sewickley, PA)</option>
<option>Erie First Christian (Erie, PA)</option>
<option>Evangel Heights Christian (Sarver, PA)</option>
<option>Faith Heritage School (Syracuse, NY)</option>
<option>First Baptist Academy (Dallas, TX)</option>
<option>Grace Brethren Christian (Clinton, MD)</option>
<option>Great Commission Schools (Altoona, PA)</option>
<option>Heartland Christian (Columbiana, OH)</option>
<option>High Point Christian (High Point, NC)</option>
<option>Juniata Mennonite (McAlisterville, PA)</option>
<option>King's High School (Shoreline, WA)</option>
<option>Lexington Christian (Lexington, KY)</option>
<option>Liberty Christian (Columbus, OH)</option>
<option>Linfield Christian (Temecula, CA)</option>
<option>Lynden Christian (Lynden, WA)</option>
<option>Merritt Island Christian (Merritt Island, FL)</option>
<option>Mifflin County Christian (McClure, PA)</option>
<option>Morningside Academy (Port St. Lucie, FL)</option>
<option>Norfolk Christian (Norfolk, VA)</option>
<option>Northeast Christian (Kingwood, TX)</option>
<option>Northumberland Christian (Northumberland, PA)</option>
<option>Oaks Christian (Westlake Village, CA)</option>
<option>Oakwood Christian (Troy, NY)</option>
<option>Oklahoma Christian Academy (Edmond, OK)</option>
<option>Oklahoma Christian School (Edmond, OK)</option>
<option>Our Savior New American (Centereach, NY)</option>
<option>Pella Christian (Pella, IA)</option>
<option>Peoria Christian (Peoria, IL)</option>
<option>Phil-Mont Christian (Erdenheim, PA)</option>
<option>Portersville Christian (Portersvile, PA)</option>
<option>Riverdale Baptist (Upper Marlboro, MD)</option>
<option>Robinson Township Christian (McKees Rocks, PA)</option>
<option>San Jacinto Christian (Amarillo, TX)</option>
<option>Shenandoah Valley Christian (Stephens City, VA)</option>
<option>Sioux Falls Christian (Sioux Falls, SD)</option>
<option>South Shore Christian (Weymouth, MA)</option>
<option>The Master's Academy (Oviedo, FL)</option>
<option>Trinity Christian (Montville, NJ)</option>
<option>Trinity Christian (Pittsburgh, PA)</option>
<option>Turlock Christian (Turlock, CA)</option>
<option>Upland Christian (Upland, CA)</option>
<option>Vacaville Christian (Vacaville, CA)</option>
<option>Veritas Christian (Fletcher, NC)</option>
<option>Veritas Christian (Lawrence, KS)</option>
<option>Wesleyan School (Norcross, GA)</option>
<option>Westminster Academy (Fort Lauderdale, FL)</option>
<option>Westminster Christian (Opelousas, LA)</option>
<option>Wheaton Academy (West Chicago, IL)</option>
<option>Wilmington Christian (Hockessin, DE)</option>
<option>Wilson Christian (West Mifflin, PA)</option>
<option>Xenia Christian (Xenia, OH)</option>
<option>Zion Christian (Columbia, TN)</option>
</select></p>
<p align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="left" style="margin-top: 0; margin-bottom: 0">Total Number of
Students in High School (Grades 9-12):
<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x"
b-value-required="TRUE" i-minimum-length="1" i-maximum-length="4" -->
<input type="text" name="HS_Enrollment" size="8" tabindex="2"
maxlength="4"></p>
<p align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<table border="1" style="border-collapse: collapse" width="93%" id="table5">
<tr>
<td width="13%"><font size="2">Player's Last Name:</font></td>
<td width="22%" colspan="2"> <!--webbot bot="Validation"
s-data-type="String" b-value-required="TRUE" i-minimum-length="2"
i-maximum-length="30" --><input type="text" name="Last_Name" size="32"
tabindex="3" maxlength="30"></td>
<td width="13%"><font size="2">Player's First Name:</font></td>
<td width="13%" colspan="2"> <!--webbot bot="Validation"
s-data-type="String" b-value-required="TRUE" i-minimum-length="2"
i-maximum-length="30" --><input type="text" name="First_Name" size="32"
tabindex="4" maxlength="30"></td>
<td width="13%"><font size="2">Year in School:</font></td>
<td width="11%"> <!--webbot bot="Validation" b-value-required="TRUE"
b-disallow-first-item="TRUE" --><select size="1" name="Grade" tabindex="5">
<option>Select a grade.</option>
<option>Senior</option>
<option>Junior</option>
<option>Sophomore</option>
<option>Freshman</option>
<option>Grade 8</option>
<option>Grade 7</option>
</select></td>
</tr>
<tr>
<td width="13%" colspan="8"> </td>
</tr>
<tr>
<td width="13%"><font size="2">Games Played:</font></td>
<td width="11%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" b-value-required="TRUE" i-minimum-length="1"
i-maximum-length="2" --><input type="text" name="Games_Played" size="11"
tabindex="6" maxlength="2"></td>
<td width="13%"> </td>
<td width="13%"> </td>
<td width="13%"> </td>
<td width="11%"> </td>
<td width="13%"> </td>
<td width="11%"> </td>
</tr>
<tr>
<td width="13%"><font size="2">Shots at Goal:</font></td>
<td width="11%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" i-maximum-length="3" --><input type="text"
name="Shots_At_Goal" size="11" tabindex="7" maxlength="3"></td>
<td width="13%"><font size="2">Goals Scored:</font></td>
<td width="13%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" i-maximum-length="3" --><input type="text"
name="Goals_Scored" size="11" tabindex="8" maxlength="3"></td>
<td width="13%"><font size="2">Assists:</font></td>
<td width="11%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" i-maximum-length="3" --><input type="text"
name="Assists" size="11" tabindex="9" maxlength="3"></td>
<td width="13%"> </td>
<td width="11%"> </td>
</tr>
<tr>
<td width="13%" colspan="8"> </td>
</tr>
<tr>
<td width="13%" height="32"><u><b><i>Goaltenders</i></b></u><i><u><b>
Only</b></u><b>:</b></i></td>
<td width="11%" height="32"> </td>
<td width="13%" height="32"> </td>
<td width="13%" height="32"> </td>
<td width="13%" height="32"> </td>
<td width="11%" height="32"> </td>
<td width="13%" height="32"> </td>
<td width="11%" height="32"> </td>
</tr>
<tr>
<td width="13%"><font size="2">Goals Allowed:</font></td>
<td width="11%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" i-maximum-length="3" --><input type="text"
name="Goals_Allowed" size="11" tabindex="10" maxlength="3"></td>
<td width="13%"><font size="2">Saves:</font></td>
<td width="13%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" b-value-required="TRUE" i-maximum-length="3"
--><input type="text" name="Saves" size="11" tabindex="11" maxlength="3"></td>
<td width="13%"><font size="2">Shutouts:</font></td>
<td width="11%"> <!--webbot bot="Validation" s-data-type="Integer"
s-number-separators="x" i-maximum-length="2" --><input type="text"
name="Shutouts" size="11" tabindex="12" maxlength="2"></td>
<td width="13%"> </td>
<td width="11%"> </td>
</tr>
</table>
<p align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<p align="center" style="margin-top: 0; margin-bottom: 0">
<input type="submit" value="Submit" name="B3" tabindex="13"><input
type="reset" value="Reset" name="B4" tabindex="14"></p>
</form>
</td>
</tr>
</table>
<p align="center">
©<font face="Times New Roman"> Copyright 2006 NCSAA. All rights
reserved.</font></p>
</body>
</html>