Builds,interactive,product,price,calculator,f
Quick Search for:  in language:    
Builds,interactive,product,price,calculator,f
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Java/ Javascript Stats

 Code: 155,451 lines
 Jobs: 364 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Java/ Javascript.
Protect Your Source Code ??
By christopher.rav en on 10/18


format date
By Sam Collett on 10/18


Click here to see a screenshot of this code!Applicant assessment
By SP Tang on 10/18

(Screen Shot)

Emulated Typewriter
By Mike Powers on 10/17


Click here to see a screenshot of this code!Java-Asp chat
By Paul R. Richards on 10/17

(Screen Shot)

Click here to see a screenshot of this code!The Data Markup Language
By Tanwani Anyangwe on 10/16

(Screen Shot)

ordered binary tree
By Eric Repec InetSolution on 10/16


Infinite tree w/XML
By Eric Repec InetSolution on 10/16


Click here to see a screenshot of this code!Shiznit Javascript Color Picker
By Chris Towers on 10/15

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Build A Dynamic Interactive Price List From A Database

Print
Email
 
VB icon
Submitted on: 6/2/2000 9:56:48 AM
By: Ary 
Level: Intermediate
User Rating: By 2 Users
Compatibility:JavaScript

Users have accessed this code 6610 times.
 
(About the author)
 
     Builds an interactive product price calculator from a database. Uses Server-side VBScript and Client-side JavaScript.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Build A Dynamic Interactive Pri
//     ce List From A Database
// Description:Builds an interactive pro
//     duct price calculator from a database. U
//     ses Server-side VBScript and Client-side
//     JavaScript.
// By: Ary
//
// Inputs:Product Type
Currency Used
//
// Returns:Products Selected
Overall Price (so that it can then accept credit card details, etc)
//
// Assumes:This code will not work strai
//     ght away, it is mainly to explain haw it
//     's done.
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.1860/lngWId.2/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

<%@ Language=VBScript %>
<!--#include file="../db.inc"-->
<%
Response.Buffer=true
Response.Expires=Now()+1
const adOpenKeySet = 1
const adLockReadOnly = 1
strScriptName = Request.ServerVariables("SCRIPT_NAME")
	Set rsAdd = Server.CreateObject("ADODB.Recordset")
	Set rs = Server.CreateObject("ADODB.Recordset")
	Set rsPP = Server.CreateObject("ADODB.Recordset")
'Get table to work on 
Dim SoftTitle 
Select case Request.QueryString("ProdID")
		case "CHK": SoftTitle = "Socks"
		case "DBI": SoftTitle = "Trousers"
		case "NOT": SoftTitle = "Shirts"
		case "PRO": SoftTitle = "skirts"
		case "RET": SoftTitle = "dresses"
		case "TRK": SoftTitle = "shorts"
		case "TRS": SoftTitle = "t-shirts"
	End Select
sSQL = "SELECT * FROM items WHERE type = '" & Request.QueryString("ProdID") & "'"
rs.open sSQL,db,adOpenKeySet,adLockReadOnly
	' Get currency to use
dim PriceType
Dim PriceIcon
Select case Request.QueryString("Currency")
		case "UK"
			PriceType = "uk"
			PriceIcon = "£"
		case "US"
			PriceType = "us"
			PriceIcon = "$"
		case "EU"
			PriceType = "euro"
			PriceIcon = "€"
	end select
%>
<HTML>
<HEAD>
<TITLE>Build Price Calculator From Database</TITLE>
<style>
	BODY{font-family: Verdana, Arial, sans-serif; font-size: 10pt;}
	TABLE{font-family: Verdana, Arial, sans-serif; font-size: 8pt;}
	H1{font-family: Verdana, Arial, sans-serif; font-size: 24pt;}
	H2{font-family: Verdana, Arial, sans-serif; font-size: 20pt;}
	H3{font-family: Verdana, Arial, sans-serif; font-size: 14pt;}
	H4{font-family: Verdana, Arial, sans-serif; font-size: 12pt;}
</style>
<SCRIPT LANGUAGE=JAVASCRIPT>
function roundOff(value, precision)
    {
    value = "" + value
    precision = parseInt(precision);
    var whole = "" + Math.round(value * Math.pow(10, precision));
    var decPoint = whole.length - precision;
    if(decPoint != 0)
        {
        result = whole.substring(0, decPoint);
        result += ".";
        result += whole.substring(decPoint, whole.length);
    }

else { result = whole; }
return result; }
</SCRIPT> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#333399" ALINK="#00FFFF" VLINK="#339999"> <DIV ALIGN="center"> <!-- Header Start--> <TABLE CELLPADDING='0' CELLSPACING='0' BORDER='0' WIDTH='100%'> <TR> <TD BGCOLOR='#3399CC'> <FONT COLOR='#FFFFFF' SIZE='5'><STRONG>  Price Calculator</STRONG></FONT> </TD> </TABLE> <!-- Header End--> <FORM NAME="PriceForm" METHOD="get" ACTION="orderupdate.asp"> <INPUT TYPE="hidden" NAME="ProdID" value="<% Response.Write(Request.QueryString("ProdID")) %>"> <INPUT TYPE="hidden" NAME="Currency" value="<% Response.Write(Request.QueryString("Currency")) %>"> <TABLE CELLSPACING='1' CELLPADDING='1' BORDER='0' WIDTH='100%'> <TR BGCOLOR='#000066'> <TD BGCOLOR='#6699CC' WIDTH="100%" COLSPAN="5"> <CENTER><FONT SIZE="4" COLOR="#FFFFFF"><STRONG><% Response.Write(SoftTitle) %></STRONG></FONT></CENTER> </TD> </TR> <TR BGCOLOR='#D0D0D0'> <TD WIDTH="10%" ALIGN="center"><FONT SIZE="2" COLOR="#000066"><STRONG>Item Code</STRONG></FONT></TD> <TD WIDTH="60%" ALIGN="center"><FONT SIZE="2" COLOR="#000066"><STRONG>Product</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><FONT SIZE="2" COLOR="#000066"><STRONG>Unit Price (<% Response.Write(PriceIcon) %>)</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><FONT SIZE="2" COLOR="#000066"><STRONG>Units</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><FONT SIZE="2" COLOR="#000066"><STRONG>Total Amount</STRONG></FONT></TD> </TR> <% if Not rs.BOF And Not rs.EOF Then for intRecord = 0 To rs.RecordCount - 1 %> <TR> <INPUT TYPE="hidden" NAME="P<% Response.Write(rs.Fields("code")) %>" value="<% Response.Write(rs.Fields(PriceType)) %>"> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><FONT COLOR="#000066"><% Response.Write(rs.Fields("code")) %></FONT></TD> <TD WIDTH="60%" VALIGN="top" ALIGN="left"><FONT COLOR="#000000"><STRONG><% Response.Write(rs.Fields("package")) %></STRONG></FONT></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="left"><FONT COLOR="#000066"><% Response.Write(rs.Fields(PriceType)) %></FONT></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><INPUT NAME="Q<% Response.Write(rs.Fields("code")) %>" SIZE="4" Value="0" onChange="S<% Response.Write(rs.Fields("code")) %>()"></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><INPUT NAME="T<% Response.Write(rs.Fields("code")) %>" SIZE="8" Value="0.00"></TD> </TR> <% Response.Write("<SCRIPT LANGUAGE=JAVASCRIPT> ") Response.Write("function S" & rs.Fields("code").Value & "() { ") Response.Write("document.PriceForm.T" & rs.Fields("code").Value & ".value = roundOff(eval(document.PriceForm.Q" & rs.Fields("code").Value & ".value * document.PriceForm.P" & rs.Fields("code").Value & ".value),2); ") Response.Write("updateTotals(); ") Response.Write(" } ") Response.Write("</SCRIPT>") rs.MoveNext Next End if %> <TR><TD COLSPAN="5"><HR COLOR="#000066"></TD></TR> <% sSQL = "SELECT * FROM items WHERE type = 'CON'" rsAdd.Open sSQL,db,adOpenKeySet,adLockReadOnly if Not rsAdd.BOF And Not rsAdd.EOF Then for intRecord = 0 To rsAdd.RecordCount - 1 %> <TR> <INPUT TYPE="hidden" NAME="P<% Response.Write(rsAdd.Fields("code")) %>" value="<% Response.Write(rsAdd.Fields(PriceType)) %>"> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><FONT COLOR="#000066"><% Response.Write(rsAdd.Fields("code")) %></FONT></TD> <TD WIDTH="60%" VALIGN="top" ALIGN="left"><FONT COLOR="#000000"><STRONG><% Response.Write(rsAdd.Fields("package")) %></STRONG></FONT></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="left"><FONT COLOR="#000066"><% Response.Write(rsAdd.Fields(PriceType)) %></FONT></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><INPUT NAME="Q<% Response.Write(rsAdd.Fields("code")) %>" SIZE="4" Value="0" onChange="S<% Response.Write(rsAdd.Fields("code")) %>()"></TD> <TD WIDTH="10%" VALIGN="top" ALIGN="center"><INPUT NAME="T<% Response.Write(rsAdd.Fields("code")) %>" SIZE="8" Value="0.00"></TD> </TR> <% Response.Write("<SCRIPT LANGUAGE=JAVASCRIPT> ") Response.Write("function S" & rsAdd.Fields("code").Value & "() { ") Response.Write("document.PriceForm.T" & rsAdd.Fields("code").Value & ".value = roundOff(eval(document.PriceForm.Q" & rsAdd.Fields("code").Value & ".value * document.PriceForm.P" & rsAdd.Fields("code").Value & ".value),2); ") Response.Write("updateTotals(); ") Response.Write(" } ") Response.Write("</SCRIPT>") rsAdd.MoveNext Next End if %> <TR><TD COLSPAN="5"><HR COLOR="#000066"></TD></TR> <TR> <TD WIDTH="70%" ALIGN="left" COLSPAN="2"><FONT SIZE="2" COLOR="#000066"><STRONG>Support & Maintenance:</STRONG></FONT><BR> <FONT SIZE="1" COLOR="#000066"><I>Support and maintenance costs 15% of the prevailing licence price per annum and is mandatory for the first year. The maintenance charge for additional licences is pro-rated to the contract renewal date.</I></FONT></TD> <TD WIDTH="20%" ALIGN="right" COLSPAN="2"></TD> <TD WIDTH="10%" ALIGN="center"><INPUT NAME="Support" SIZE="8" Value="<% Response.Write("0.00") %>" ALIGN="right"></TD> </TR> <TR><TD COLSPAN="5"><HR COLOR="#000066"></TD></TR> <% sSQL = "SELECT * FROM items WHERE code = 'SER03'" rsPP.Open sSQL,db,adOpenKeySet,adLockReadOnly if Not rsPP.BOF And Not rsPP.EOF Then rsPP.movefirst %> <INPUT TYPE="hidden" NAME="PP" value="<% Response.Write(rsPP.Fields(PriceType)) %>"> <TR> <TD WIDTH="70%" ALIGN="left" COLSPAN="2"><FONT SIZE="2" COLOR="#000066"><STRONG>Postage & Packing:</STRONG></FONT><BR> <FONT SIZE="1" COLOR="#000066"><I>Postage and packing is mandatory on all orders.</I></FONT></TD> <TD WIDTH="20%" ALIGN="right" COLSPAN="2"></TD> <TD WIDTH="10%" ALIGN="center"><% Response.Write(PriceIcon & rsPP.Fields(PriceType)) %></TD> </TR> <TR><TD COLSPAN="5"><HR COLOR="#000066"></TD></TR> <TR> <TD WIDTH="90%" ALIGN="right" COLSPAN="4"><FONT SIZE="2" COLOR="#000066"><STRONG>Total:</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><INPUT NAME="Gross" SIZE="8" Value="<% Response.Write("0.00") %>" ALIGN="right"></TD> </TR> <TR> <TD WIDTH="90%" ALIGN="right" COLSPAN="4"><FONT SIZE="2" COLOR="#000066"><STRONG>VAT (17.5%):</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><INPUT NAME="Tax" SIZE="8" Value="<% Response.Write("0.00") %>" ALIGN="right"></TD> </TR> <TR> <TD CLASS='3dRaised' BGCOLOR='#6699CC' WIDTH="90%" ALIGN="right" COLSPAN="4"><FONT SIZE="2" COLOR="#FFFFFF"><STRONG>final Total:</STRONG></FONT></TD> <TD WIDTH="10%" ALIGN="center"><INPUT NAME="TotalValue" SIZE="8" Value="<% Response.Write("0.00") %>" ALIGN="right"></TD> </TR> <TR BGCOLOR="#FFFFFF"> <TD WIDTH="100%" ALIGN="right" COLSPAN="5"><BR><BR> <INPUT TYPE='reset' name='reset1' value='Begin Again' STYLE='BACKGROUND:#6699CC;COLOR:#FFFFFF'> <INPUT TYPE='submit' name='submit' value='Add To Order' STYLE='BACKGROUND:#6699CC;COLOR:#FFFFFF'> </TD> </TR> </TABLE> </DIV> </FORM> <% Response.Write("<SCRIPT LANGUAGE=JAVASCRIPT> " + VBCRLF) Response.Write("function updateTotals() { " + VBCRLF) Response.Write("var SoftTotal;" + VBCRLF) Response.Write("var AddTotal;" + VBCRLF) Response.Write("var TaxTotal;" + VBCRLF) Response.Write("var SupportTotal;" + VBCRLF) Response.Write("var GrossTotal;" + VBCRLF) Response.Write("var PPTotal;" + VBCRLF) Response.Write("var FullTotal;" + VBCRLF) Response.Write("SoftTotal = ") rs.MoveFirst for intRecord = 0 To rs.RecordCount - 1 Response.Write("eval(document.PriceForm.T" & rs.Fields("code").Value & ".value") if Not intRecord = rs.RecordCount - 1 Then Response.Write(") + ") else Response.Write("); " + VBCRLF) End if rs.MoveNext Next Response.Write("AddTotal = ") rsAdd.MoveFirst for intRecord = 0 To rsAdd.RecordCount - 1 Response.Write("eval(document.PriceForm.T" & rsAdd.Fields("code").Value & ".value") if Not intRecord = rsAdd.RecordCount - 1 Then Response.Write(") + ") else Response.Write("); " + VBCRLF) End if rsAdd.MoveNext Next Response.Write("PPTotal = eval(document.PriceForm.PP.value); " + VBCRLF) Response.Write("SupportTotal = eval(SoftTotal / 100) * 15; " + VBCRLF) Response.Write("document.PriceForm.Support.value = roundOff(SupportTotal,2); " + VBCRLF) Response.Write("GrossTotal = SoftTotal + AddTotal + SupportTotal + PPTotal; " + VBCRLF) Response.Write("document.PriceForm.Gross.value = roundOff(GrossTotal,2); " + VBCRLF) Response.Write("TaxTotal = eval(document.PriceForm.Gross.value / 100) * 17.5; " + VBCRLF) Response.Write("document.PriceForm.Tax.value = roundOff(TaxTotal,2); " + VBCRLF) Response.Write("FullTotal = TaxTotal + GrossTotal; " + VBCRLF) Response.Write("document.PriceForm.TotalValue.value = roundOff(FullTotal,2); " + VBCRLF) Response.Write("} " + VBCRLF) Response.Write(" </SCRIPT>" + VBCRLF) %> </BODY> </HTML>

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Java/ Javascript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.