Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP with Javascript calculation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP with Javascript calculation

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: ASP with Javascript calculation
    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=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>"
%>
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 7:49pm
Well, what's the error?
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Posted: 16 November 2003 at 9:43pm

It's ok. I have changed plan.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.