You are on page 1of 8

PROGRAMS

book.html

<html>

<head>

<title>book</title>

<script type="text/vbscript">

Option Explicit

Dim sum

sum=0

Sub book1_OnClick()

If Document.Forms( 0 ).book1.CHECKED=True Then

sum=sum+Document.Forms( 0 ).book1.value

Else

sum=sum-Document.Forms( 0 ).book1.value

End If

Document.Forms( 0 ).tb1.value=sum

End Sub

Sub book2_OnClick()

If Document.Forms( 0 ).book2.CHECKED=True Then

sum=sum+Document.Forms( 0 ).book2.value

Else

sum=sum-Document.Forms( 0 ).book2.value

End If

Document.Forms( 0 ).tb1.value=sum

End Sub
Sub book3_OnClick()

If Document.Forms( 0 ).book3.CHECKED=True Then

sum=sum+Document.Forms( 0 ).book3.value

Else

sum=sum-Document.Forms( 0 ).book3.value

End If

Document.Forms( 0 ).tb1.value=sum

End Sub

Sub book4_OnClick()

If Document.Forms( 0 ).book4.CHECKED=True Then

sum=sum+Document.Forms( 0 ).book4.value

Else

sum=sum-Document.Forms( 0 ).book4.value

End If

Document.Forms( 0 ).tb1.value=sum

End Sub

Sub book5_OnClick()

If Document.Forms( 0 ).book5.CHECKED=True Then

sum=sum+Document.Forms( 0 ).book5.value

Else

sum=sum-Document.Forms( 0 ).book5.value

End If

Document.Forms( 0 ).tb1.value=sum

End Sub

</script></head>

<body>

<form action="">
<p style="color:blue;font-family:Monotype Corsiva;font-size:15pt">Available books:</p>

<table border="1" width="50%">

<tr><th>Book</th>

<th>Price</th>

<th>Select</th></tr>

<tr><td>OS</td>

<td>Rs.450</td>

<td><input name = "book1" type = "checkbox" value = "450" /></td></tr>

<tr><td>DBT</td>

<td>Rs.560</td>

<td><input name = "book2" type = "checkbox" value = "560" /></td></tr>

<tr><td>OOSD</td>

<td>Rs.350</td>

<td><input name = "book3" type = "checkbox" value = "350" /></td></tr>

<tr><td>WT</td>

<td>Rs.750</td>

<td><input name = "book4" type = "checkbox" value = "750" /></td></tr>

<tr><td>IS</td>

<td>Rs.250</td>

<td><input name = "book5" type = "checkbox" value = "250" /></td></tr>

</table><br>

<p style="color:magenta;font-size:15pt;font-family:Monotype Corsiva">

current total:</p>

<input type="text" name="tb1"/>

</form>

</body>

</html>
calc.html

<html>

<head>

<title>Our first VBScript</title>

<script type = "text/vbscript">

Option Explicit

Dim n1,n2,op

Sub num1_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num1.Value

End Sub

Sub num2_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num2.Value

End Sub

Sub num3_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num3.Value

End Sub

Sub num4_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num4.Value

End Sub

Sub num5_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num5.Value

End Sub
Sub num6_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num6.Value

End Sub

Sub num7_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num7.Value

End Sub

Sub num8_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num8.Value

End Sub

Sub num9_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num9.Value

End Sub

Sub num0_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).num0.Value

End Sub

Sub dot_OnClick()

Document.Forms( 0 ).tb1.Value=Document.Forms( 0 ).tb1.Value &


Document.Forms( 0 ).dot.Value

End Sub

Sub op1_OnClick()

n1=CDbl(Document.Forms( 0 ).tb1.Value)

Document.Forms( 0 ).tb1.Value=""

op=1

End Sub
Sub op2_OnClick()

n1=CDbl(Document.Forms( 0 ).tb1.Value)

Document.Forms( 0 ).tb1.Value=""

op=2

End Sub

Sub op3_OnClick()

n1=CDbl(Document.Forms( 0 ).tb1.Value)

Document.Forms( 0 ).tb1.Value=""

op=3

End Sub

Sub op4_OnClick()

n1=CDbl(Document.Forms( 0 ).tb1.Value)

Document.Forms( 0 ).tb1.Value=""

op=4

End Sub

Sub eq_OnClick()

n2=CDbl(Document.Forms( 0 ).tb1.Value)

Select Case op

Case 1

Document.Forms( 0 ).tb1.Value=n1+n2

Case 2

Document.Forms( 0 ).tb1.Value=n1-n2

Case 3

Document.Forms( 0 ).tb1.Value=n1*n2

Case 4

Document.Forms( 0 ).tb1.Value=n1/n2

End Select
End Sub

</script>

</head>

<body>

<form action = "">

<h3 style="color:blue">Calculator</h3>

<br>

<table width="20%">

<tr>

<td><input name = "num1" type = "button" value = "1" /></td>

<td><input name = "num2" type = "button" value = "2" /></td>

<td><input name = "num3" type = "button" value = "3" /></td>

<td><input name = "op1" type = "button" value = "+" /></td>

</tr>

<tr>

<td><input name = "num4" type = "button" value = "4" /></td>

<td><input name = "num5" type = "button" value = "5" /></td>

<td><input name = "num6" type = "button" value = "6" /></td>

<td><input name = "op2" type = "button" value = "-" /></td>

</tr>

<tr>

<td><input name = "num7" type = "button" value = "7" /></td>

<td><input name = "num8" type = "button" value = "8" /></td>

<td><input name = "num9" type = "button" value = "9" /></td>

<td><input name = "op3" type = "button" value = "*" /></td>

</tr>

<tr>
<td><input name = "num0" type = "button" value = "0" /></td>

<td><input name = "dot" type = "button" value = "." /></td>

<td><input name = "eq" type = "button" value = "=" /></td>

<td><input name = "op4" type = "button" value = "/" /></td>

</tr>

</table>

<br>

<br>

<input type="text" name="tb1" value=""/>

</form>

</body>

</html>

You might also like