Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript - checkbox total calculation

Status
Not open for further replies.
Feb 21, 2003
2
GB
I am trying to calculate the total cost of four items using checkboxes but getting back type mismatch for my "Calculate" function (see code extract below) - can you please tell me where I am going wrong? Any help would be greatly appreciated.

<head>
<SCRIPT LANGUAGE=&quot;VBScript&quot; type=&quot;text/vbscript&quot;>
<!--
Option Explicit
Dim curTotal

Sub Calculate
Dim MyForm
Set MyForm=Document.frmRegister
If MyForm.chkBOOK1.Checked Then
curTotal=curTotal+10
End If
MyForm.lblTotal.Caption=&quot;£&quot; & curTotal & &quot;.00&quot;
MyForm.txtTotal.Value=curTotal
End Sub
-->
</SCRIPT>
</head>

<body>
<TD COLSPAN=6>
<FORM NAME=&quot;frmRegister&quot; METHOD=&quot;POST&quot; ACTION=&quot;&quot; >

<TABLE WIDTH=400 BORDER=0>
<B><FONT SIZE=2>
<TR>
<TD COLSPAN=1>
</TD>
<TD NOWRAP COLSPAN=1>
<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;chkBOOK1&quot;
VALUE=&quot;Yes&quot; OnClick=&quot;Calculate&quot;>
BOOK1 £10 </br>
</TD>
<TD NOWRAP COLSPAN=1>
<INPUT TYPE=&quot;CHECKBOX&quot;
<OBJECT
ID=&quot;lblTotal&quot;
HEIGHT=20
WIDTH=100
>
<PARAM NAME=&quot;ForeColor&quot; VALUE=&quot;#000000&quot;>
<PARAM NAME=&quot;Caption&quot; VALUE=&quot;£50.00&quot;>
<PARAM NAME=&quot;BackStyle&quot; VALUE=&quot;0&quot;>
<PARAM NAME=&quot;FontName&quot; VALUE=&quot;Arial&quot;>
<PARAM NAME=&quot;FontSize&quot; VALUE=&quot;20&quot;>
<PARAM NAME=&quot;FontBold&quot; VALUE=&quot;True&quot;>
<PARAM NAME=&quot;Visible&quot; VALUE=&quot;True&quot;>
</OBJECT>
<INPUT TYPE=&quot;Text&quot; NAME=&quot;txtTotal&quot; VALUE=&quot;50&quot;>

</TD>
</TR>
<TR>
<TD COLSPAN=3 ALIGN=&quot;CENTER&quot;>

<INPUT TYPE=&quot;SUBMIT&quot;>
<INPUT TYPE=&quot;RESET&quot;>
</TABLE>
</FORM>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top