Print Page | Close Window

ASP with Javascript calculation

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7287
Printed Date: 31 March 2026 at 5:51pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP with Javascript calculation
Posted By: ngaisteve1
Subject: ASP with Javascript calculation
Date Posted: 14 November 2003 at 10:16pm
What I am trying to work on is about calculation. (refer to attchment - http://www.htmlforums.com/attachment.php?s=&postid=198089 - http://www.htmlforums.com/attachment.php?s=&postid=19808 9 ). The price is readonly but the quantity is changable. What I want is the total colum will automatically calculate (price * quantity) with onchange of quantity textbox. Meaning when there is any changes of quantity texbox's value, then total column value will automatically calculated.

My existing code is below but I wonder if this way works:

function calculate()
{
tempquantity = document.myform.quantity_fr.value;
tempprice = document.myform.price_fr.value;
temptotal = tempquantity * tempprice;
}
document.myform.total_fr.value = temptotal
}

<%
DO WHILE NOT rs.eof
response.Write "<tr valign=top><td>" & rs("pName") & "</td>"
response.write "<td nowrap>" & rs("PCategory") & " </td>"
response.write "<td nowrap>" & rs("PType") & " </td>"
response.write "<td nowrap align=right><input type=text name=price_fr size=5 readonly value=" & rs("PPrice") & "> </td>"
response.Write "<td nowrap><input type=text name=quantity_fr size=5 maxlength=6 value=" & rs("quantity") & " onChange='calculate();'></td>"
response.write "<td nowrap align=right><input type=text name=total_fr size=5 readonly></td>"
response.write "<td><input type=hidden name='productID_fr' value=" & rs("RDetails.ProductID") & "></td></tr>"
strGrandTotal = cdbl(strGrandTotal) + cdbl(strTotal)
rs.MoveNext
LOOP
response.write "<tr><td colspan=6 align=right bgcolor=orange><b>Grand Total = " & FormatNumber(strGrandTotal,2) & "</b></td></tr>"
%>



Replies:
Posted By: MorningZ
Date Posted: 15 November 2003 at 6:14am

are you aking how to do it?
are you asking how to fix the code you posted?
do you run into errors here?
what do you want people to reply with????



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: ngaisteve1
Date Posted: 16 November 2003 at 6:18pm
Sorry for not being descriptive enough. Yeah, I run into error and at the same I want to seek advice if that method/script works.


Posted By: michael
Date Posted: 16 November 2003 at 7:49pm
Well, what's the error?

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ngaisteve1
Date Posted: 16 November 2003 at 9:43pm

It's ok. I have changed plan.



Posted By: MorningZ
Date Posted: 17 November 2003 at 6:28am

Originally posted by michael michael wrote:

Well, what's the error?

lol.. i was thinking the same exact thing

people on this forum: if you are looking for help, it sure in heck helps if you at least make an attempt of being descriptive in what's wrong other than the useless "i got an error"....



-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net