Using Radio buttons/checkboxes to add values into numeric calculations

N

Newbie

I currently have a set of simple calculations to determine square footage
and multuply that by a dollar amount per foot. I use form fields that are
filled in by the user, and then the Submit button opens the asp page that
returns the result of the calculation. What I would like to do is add
certain numbers to the total based on radio buttons or checkboxes that the
user activates on the form page. For instance, they enter the numbers into
the form fields, and then if they check Radio Button 1, 100 is added to the
total on the asp results page. I tried using the "Value" attribute of the
Radio buttons and "+ cInt("RadioButtonName") in the results ASP code, but
this apparently should only be "on" or "off," not return custom values.

I am using Frontpage and very rudimentary ASP code. Can anyone help?

Thanks in advance, help is much appreciated. If you know a place that this
post is better posted, please let me know.

Newbie Supreme
 
T

Tom B

You should show the code you are using. Anyway.

Page1.asp
<form method=post action=Page2.asp>
Enter the length <input name=theLength><br>
Enter the width <input name=theWidth><br>
How much extra would you like to pay?<br>
<input type=radio name=PayExtra value=100>$100
<input type=radio name=PayExtra value=10>$10
<input type=radio name=PayExtra value=1>$1
<input type=radio name=PayExtra value=0>$0
<br>
<input type=submit value="GO">
</form>

Page2.asp
<%
Dim lngLength
Dim lngWidth
Dim dblPayExtra
Dim lngSqrFeet
Dim dblBaseCharge

dblBaseCharge=10 'That is, $10 per square foot
lngLength=Request.Form("theLength")
lngWidth=Request.Form("theWidth")
dblPayExtra=Request.Form("PayExtra")
lngSqrFeet=lngLength*lngWidth

Response.Write "Your bill will be.....$" & (lngSqrFeet * dblBaseCharge)
+ dblPayExtra
%>
 
N

Newbie

Now THAT did the trick. You know, I tried using the value attribute of the
radio buttons, but I must have had the syntax wrong. I probably hadn't
declared the variables properly.

Thanks again!

Newbie Supreme
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top