Banksy
05-05-2003, 02:59 PM
Here is the problem that I am experiencing with this my assignment. I need to calculate an individuals NetPay after using Checkboxes to determine if they will have CPP Deducted, EI Deducted and/or Health Care Deducted:
Here is the coding I have so far:
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<% Dim Connection, Query, Data
Set Connection = Server.CreateObject( "ADODB.Connection" )
Call Connection.Open( "dsnCCNT397" )
' Create the SQL query
Query = "SELECT PLvls FROM PayLevels"
' Create the recordset
Set Data = Server.CreateObject( "ADODB.Recordset" )
Call Data.Open( Query, Connection )
' If an error occurs, ignore it
On Error Resume Next
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>PayRoll ASP</TITLE></HEAD>
<BODY>
<% ' If this is a return after a failed attempt, print an error
If Session( "Failed" ) = True Then %>
<FONT SIZE = "4" COLOR = "Red"> One Or More Fields Have Information Missing, Please Try Again</FONT>
<% End If %>
<% ' Begin the form %>
<FORM ACTION = "Payroll.asp" METHOD = "POST" NAME = "ASP">
<% ' Format the form using a table %>
<CENTER>
<TABLE>
<TR>
<TD>
EEID:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEID">
</TD>
</TR>
<TR>
<TD>
Employee Name:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEName">
</TD>
</TR>
<TR>
<TD>
Position:
</TD>
<TD>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Manager"> Manager
</TD>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Sales Clerk"> Sales Clerk
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Supervisor"> Supervisor
</TD>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Accountant"> Accountant
</TD>
</TR>
<TR>
<TD>
Salary:
</TD>
<TD>
<SELECT NAME = "Salary">
<OPTION VALUE = "noSelection"> Select Salary
<% Call CreateSalary() %>
</SELECT>
</TD>
</TR>
<TR>
<TD>
Hours:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEHours">
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EECPP"> CPP
</TD>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EEEI"> EI
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EEHealth"> Health Care Plan
</TD>
<TD>
</TD>
</TR>
</TABLE>
<INPUT TYPE = "Submit" VALUE = "Submit">
</CENTER>
</FORM>
</BODY>
</HTML>
<%
' Creates The OPTION Items For PLvls Without Writing SELECTED For Any PLvls
Sub CreateSalary()
' Pull PLvls List From The Recordset To Populate The Dropdown List
While Not Data.EOF
' Create This Rrecord's Dropdown Entry
%> <OPTION VALUE = "<% =Data( "PLvls" ) %>">
<% =Data( "PLvls" ) %>
<% Call Data.MoveNext()
Wend
End Sub
%>
Here is a example of one of the calculations I have:
Dim CPPAmt
' Perform Total Sale Calculation
CPPAmt = GrossPay * 0.10
Cdbl(CPPAmt)
How do I only use this calculation ONLY when CPP Checkbox is clicked?
Thanks for any ideas/suggestions!!!
Here is the coding I have so far:
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<% Dim Connection, Query, Data
Set Connection = Server.CreateObject( "ADODB.Connection" )
Call Connection.Open( "dsnCCNT397" )
' Create the SQL query
Query = "SELECT PLvls FROM PayLevels"
' Create the recordset
Set Data = Server.CreateObject( "ADODB.Recordset" )
Call Data.Open( Query, Connection )
' If an error occurs, ignore it
On Error Resume Next
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>PayRoll ASP</TITLE></HEAD>
<BODY>
<% ' If this is a return after a failed attempt, print an error
If Session( "Failed" ) = True Then %>
<FONT SIZE = "4" COLOR = "Red"> One Or More Fields Have Information Missing, Please Try Again</FONT>
<% End If %>
<% ' Begin the form %>
<FORM ACTION = "Payroll.asp" METHOD = "POST" NAME = "ASP">
<% ' Format the form using a table %>
<CENTER>
<TABLE>
<TR>
<TD>
EEID:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEID">
</TD>
</TR>
<TR>
<TD>
Employee Name:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEName">
</TD>
</TR>
<TR>
<TD>
Position:
</TD>
<TD>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Manager"> Manager
</TD>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Sales Clerk"> Sales Clerk
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Supervisor"> Supervisor
</TD>
<TD>
<INPUT TYPE = "Radio" NAME = "Position" VALUE = "Accountant"> Accountant
</TD>
</TR>
<TR>
<TD>
Salary:
</TD>
<TD>
<SELECT NAME = "Salary">
<OPTION VALUE = "noSelection"> Select Salary
<% Call CreateSalary() %>
</SELECT>
</TD>
</TR>
<TR>
<TD>
Hours:
</TD>
<TD>
<INPUT TYPE = "Text" NAME = "EEHours">
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EECPP"> CPP
</TD>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EEEI"> EI
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE = "Checkbox" NAME = "Deductions" VALUE = "EEHealth"> Health Care Plan
</TD>
<TD>
</TD>
</TR>
</TABLE>
<INPUT TYPE = "Submit" VALUE = "Submit">
</CENTER>
</FORM>
</BODY>
</HTML>
<%
' Creates The OPTION Items For PLvls Without Writing SELECTED For Any PLvls
Sub CreateSalary()
' Pull PLvls List From The Recordset To Populate The Dropdown List
While Not Data.EOF
' Create This Rrecord's Dropdown Entry
%> <OPTION VALUE = "<% =Data( "PLvls" ) %>">
<% =Data( "PLvls" ) %>
<% Call Data.MoveNext()
Wend
End Sub
%>
Here is a example of one of the calculations I have:
Dim CPPAmt
' Perform Total Sale Calculation
CPPAmt = GrossPay * 0.10
Cdbl(CPPAmt)
How do I only use this calculation ONLY when CPP Checkbox is clicked?
Thanks for any ideas/suggestions!!!