View Full Version : drop down boxes - add up to total? help please

03-25-2006, 01:26 AM

basically i need to have a page with a few drop down boxes and text boxes containing numbers that add up to a total.

for example

drop down 1 - either not selected or selected and the value is 50
drop down 2 - either not selected or selected and the value is 75
text box - user types in a number i.e 25

total box will then add up to 100.

can someone please tell me how i can do this quickly, would very much appriciate it. thanks in advance

03-27-2006, 01:45 PM
<form name="form1" method="post" action="">
<select name="num1" id="num1">
<option value="10" selected>10</option>
<option value="20">20</option>
<option value="30">30</option>
<select name="num2" id="num2">
<option value="25">25</option>
<option value="50" selected>50</option>
<input name="num3" type="text" id="num3" value="50">
<input type="submit" name="Submit" value="Add it up">
If Len(Request.Form) > 0 Then
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))

If IsNumeric(Request.Form("num3")) Then

num3 = CInt(Request.Form("num3"))
total = num1 + num2 + num3
Response.Write "Total: " & total
Response.Write "Please enter a number"
End If
End If