%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit Response.Expires = 0 Dim borderColor 'border Dim fontColor 'link font Dim cOuterBorder Dim cCellBorder Dim tColorRed Dim tColorGreen Dim tColorBlue %> <% tColorRed = Request.Form("txtColorRed") tColorGreen = Request.Form("txtColorGreen") tColorBlue = Request.Form("txtColorBlue") cOuterBorder = Request.Form("cboBorderSize") cCellBorder = Request.Form("cboCellBorder") tColorRed = validateRange(tColorRed) tColorGreen = validateRange(tColorGreen) tColorBlue = validateRange(tColorBlue) borderColor = getHexString(tColorRed, tColorGreen, tColorBlue) fontColor = checkFont(tColorRed, tColorGreen, tColorBlue) 'Defaults if cOuterBorder = "" then cOuterBorder = "1" end if if cCellBorder = "" then cCellBorder = "1" end if 'Validate function Function validateRange(num) Dim temp temp = "" If Not IsNumeric(num) Then temp = 0 ElseIf num > 255 Then temp = 255 ElseIf num < 0 Then temp = 0 Else temp = num End If validateRange = temp End Function 'Get hex string Function getHexString(r, g, b) getHexString = "#" & getHexValue(r) & getHexValue(g) & getHexValue(b) End Function 'Get hex value Function getHexValue(num) Dim temp temp = Hex(num) If Len(temp) < 2 Then temp = "0" & temp getHexValue = temp End Function 'Get the font color if too light Function checkFont(r, g, b) Dim temp If r > 230 And g > 230 And b > 200 Then temp = getHexString(0, 0, 0) Else temp = getHexString(r, g, b) End If checkFont = temp End Function %>
<%
dim i
dim nonBreakingSpace
for i = 1 to 2 '1=display, 2=html in textarea
%>
<%
if i = 1 then
nonBreakingSpace = " "
%>
The Resulting Pace Calculator
<% end if%>
<%
' Check if the textarea section
' Note: include
<% next %>
The JavaScript
For the Pace Calculator logic, include the dot-js files using the following HTML, which supplements the HTML generated above.
<script language="JavaScript" src="pacecalc.js"></script> <script language="JavaScript" src="pacecalc_example.js"></script>pacecalc.js has the core logic, and pacecalc_example.js implements it to match up with the field names in the above HTML.
Download the files here:
pacecalc.js
pacecalc_example.js
The JavaScript - Alternate Method
If you find it easier, copy the contents of the dot-js files from below. They will still need to be placed in separate files with the appropriate names. Or the code can be placed in the HTML file between <SCRIPT> tags. Refer to the MREDKJ JavaScript Intro for more information about using JavaScript.
pacecalc.js
|
MREDKJ Pace Calculators JavaScript Table of Contents MREDKJ.com
|