473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Performing Calculations - Noobie Question

Not sure if this is a stoopid question or not. If it is, my apologies.

I'd like to have an ASP form performing a relatively simple calculation.

For example, if I wanted to create a simple order form where someone enters
a quantity of tickets, the form would automatically calculate the total cost
in a second text box based on the number (qty) entered times the cost of a
single ticket. Such that, if the user entered "2" in one text box, it would
automatically generate the total cost of, say $34.00 in a second text box
based on the cost of a single ticket being $17.00.

Can someone point me to a tutorial on how to go about doing this?

TIA

SAIC69
Jul 19 '05 #1
3 4070
You can't do that from ASP so you'd need to use scripting on the client;
<form name="TestForm">
<input type=text name=txtQuantity onKeyUp="ShowTotal()"
onChange="ShowTotal()">
<input type=text name=txtTotal>
</form>

<script language=VBScript>
sub ShowTotal
on error resume next
document.TestForm.txtTotal.value = document.TestForm.txtQuantity.value * 17
on error goto 0
end sub
</script>

"special_agent69" <SA****@thess.com> wrote in message
news:us****************@TK2MSFTNGP12.phx.gbl...
Not sure if this is a stoopid question or not. If it is, my apologies.

I'd like to have an ASP form performing a relatively simple calculation.

For example, if I wanted to create a simple order form where someone enters a quantity of tickets, the form would automatically calculate the total cost in a second text box based on the number (qty) entered times the cost of a
single ticket. Such that, if the user entered "2" in one text box, it would automatically generate the total cost of, say $34.00 in a second text box
based on the cost of a single ticket being $17.00.

Can someone point me to a tutorial on how to go about doing this?

TIA

SAIC69

Jul 19 '05 #2
I was afraid of that.

Many thanks for your help

SAIC69

"Adrian Forbes [ASP MVP]" <so***@noemail.zzz> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You can't do that from ASP so you'd need to use scripting on the client;
<form name="TestForm">
<input type=text name=txtQuantity onKeyUp="ShowTotal()"
onChange="ShowTotal()">
<input type=text name=txtTotal>
</form>

<script language=VBScript>
sub ShowTotal
on error resume next
document.TestForm.txtTotal.value = document.TestForm.txtQuantity.value * 17 on error goto 0
end sub
</script>

"special_agent69" <SA****@thess.com> wrote in message
news:us****************@TK2MSFTNGP12.phx.gbl...
Not sure if this is a stoopid question or not. If it is, my apologies.

I'd like to have an ASP form performing a relatively simple calculation.

For example, if I wanted to create a simple order form where someone

enters
a quantity of tickets, the form would automatically calculate the total

cost
in a second text box based on the number (qty) entered times the cost of a single ticket. Such that, if the user entered "2" in one text box, it

would
automatically generate the total cost of, say $34.00 in a second text box based on the cost of a single ticket being $17.00.

Can someone point me to a tutorial on how to go about doing this?

TIA

SAIC69


Jul 19 '05 #3
FormPage.asp

<form method=post action=PostPage.asp>
<table>
<tr><th>Qty</th><td><input name=Qty></td></tr>
<tr><th>Price</th><td>$17.00</td></tr>
<tr><td colspan=2 align=center><input type=submit
value="calculate"></td></tr>
</table>

PostPage.asp

<%
Dim lngQty
lngQty=Request.Form("Qty")
if isNumeric(lngQty) then
Response.Write "The total is ......" & lngQty * 17.00
end if
%>

"special_agent69" <SA****@thess.com> wrote in message
news:us****************@TK2MSFTNGP12.phx.gbl...
Not sure if this is a stoopid question or not. If it is, my apologies.

I'd like to have an ASP form performing a relatively simple calculation.

For example, if I wanted to create a simple order form where someone enters a quantity of tickets, the form would automatically calculate the total cost in a second text box based on the number (qty) entered times the cost of a
single ticket. Such that, if the user entered "2" in one text box, it would automatically generate the total cost of, say $34.00 in a second text box
based on the cost of a single ticket being $17.00.

Can someone point me to a tutorial on how to go about doing this?

TIA

SAIC69

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: osgnamah | last post by:
Hi All; I am getting ready to launch a shareware program in the next few weeks and the last step is going to be creating a website. So the last few days I've been doing some web surfing in...
6
by: Aristotelis E. Charalampakis | last post by:
Hi all, this is a newbie question :-) I was wondering if there was a way to use the switch statement in a manner that each case statement includes more that a simple value. i.e.: switch (...
2
by: Scot Niklos via AccessMonster.com | last post by:
Sorry if it is way to much information but I'm trying to cover all bases Access 97 A= combobox that queries Distributor B= combobox that limits customers by distributor in a C= combobox that...
2
by: Jeronimo Bertran | last post by:
I have an aspx page that shows a complex image with several objects that are sensitive to mouseover events. The information about the objects in the image is obtained from a database and complex...
2
by: Zorpiedoman | last post by:
If I have a string, "(5+3)/8" or "23>9" Has .NET provides some sort of parser that can get me the mathematical answer? Years ago, in VB6 I found an answer to this question using some sort of...
2
by: Mike P | last post by:
Is it possible to perform calculations on data in your gridview in your ASP, or do you need to do any calculations in the OnRowDataBound event? Here is what I am trying to do : ...
22
by: robertmeyer1 | last post by:
Hi. I have been working on creating the structure of a DB and now I am trying to create some queries which will perform calculations. I have 1 table, tblAnswers which is based off an append query....
1
by: Grubsy4u | last post by:
Grubsy4u Newbie 7 Posts October 5th, 2007 11:31 AM #1 Report calculations --------------------------------------------------------------------------------
3
by: qazplm114477 | last post by:
lets say i have 1 table called Inventory and another table called itemType Inventory -itemID -PK -Desc -itemID- FK itemType -ItemID...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.