View Full Version : Looking for Instant price quote script for my site
Pinto7
12-14-2005, 05:27 AM
I have been searching the net for either and ASP, Java or ASP.net script that will allow me to put a form for customers to get an instant shipping quote.
We are a small Freight shipping company and would require the custoer to input the following fields:
Origin Zip code
Destination Zip code
Shipment wieght
Type of shipment
They the distance would need to be calculated between zip codes, and a math function would need to occur in the script to multiply the distance by a given $ per mile to give the quoted price.
Anyone know where I can atleast fine a simular script that I can probably modify?
Thanks in advance.
BarrMan
12-15-2005, 02:36 PM
What is the calculation for it? ex. result = ((value1*value2-value3)/350)*value4.
Pinto7
12-17-2005, 06:10 AM
BarrMan,
I think you got the idea... it would be somthing like
Distance * Cost Per Mile = Quoted amount.
But first the script must calculate the distance between two Zip codes.
I've had no luck trying to find anything close to this type of script.
All and any help is appriciated.
:confused:
BarrMan
12-17-2005, 10:59 AM
I'm not sure if i'm right, but i looked at w3schools and i got an idea for you:
function calDistance(zip1,zip2)
{
distance = zip1*zip2//Or whatever calculation needed.
}
function calQuotedPrice(distance,costPerMile)
{
quotedPrice = distance*costPerMile
Return quotedPrice
}
<%
response.write quotedPrice
%>
Hope that helped, if not, try posting this problem on the javascript forum or try looking at www.w3schools.com.
Pinto7
12-17-2005, 03:35 PM
BarrMan
You have given me a place to start, thats better than I've gotten so far. I'll look at it and post back what I've gotten so far.
Thanks
Pinto7
12-17-2005, 05:00 PM
I have found a free sample code for calculating distance between zip codes using lat and long's. I also have a zip code database which I can not attach dues to size. But the fields are ZIP, LAT, LON, CITY, STATE, COUNTRY.
at this pont I just need the script to take the "To" and "From" Zip code information from the form and calculate the distance. attached is the form, and Code.
FYI - At the bottom of this code already has a "Demo" out put response.write Need help in making this work, then later I can add additional functions to it.
<%
' This routine calculates the distance between two points
' (given the latitude/longitude of those points). It is being
'used to calculate distance between two ZIP Codes or Postal
'Codes using our ZIPCodeWorld(TM) and PostalCodeWorld(TM)
' products. IAM USING ACCESS DB - ZIPBASE.MDB
'Definitions
' South latitudes are negative, east longitudes are
'positive
' Passed to function
'lat1, lon1 = Latitude and Longitude of point 1
'(in decimal degrees)
'lat2, lon2 = Latitude and Longitude of point 2
'(in decimal degrees)
'unit = the unit you desire for results
'where 'M' is statute miles (default)
''K' is kilometers
'N' is nautical miles
''United States ZIP Code/ Canadian Postal Code databases with
'latitude & longitude are available at
'Hexa Software Development Center
Dim strInputSearch 'Variable for the search word
Dim strCon 'Holds the string to connect to the db
Dim adoCon 'Database Connection Variable Object
Dim strSQL 'Holds the SQL query for the database
Dim rsSearch 'Holds the search recordset
'This is the variable that has the search word
strInputSearch = Request.Form("txtSearch")
If len(strInputSearch) >= 4 Then
'This makes it so people cant inject SQL code and/or cause some unwanted
strInputSearch = Replace(strInputSearch,"'", "''", 1, -1, 1)
'This sets the connection
Set adoCon = Server.CreateObject("ADODB.Connection")
'This is the connection string
strCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &Server.MapPath("zipbase.mdb")
'Open the connection
adoCon.Open strCon
'Set the database connection
Set rsSearch = Server.CreateObject("ADODB.Recordset")
'This is the SQL statement for searching. You will need to change tblTable and Field to match your database (they are in red)
strSQL = "SELECT * FROM Zip_Code WHERE zip LIKE '%" & strInputSearch &"%';"
'Opens the database so we can get the results of the search
rsSearch.Open strSQL, adoCon
'
const pi = 3.14159265358979323846
Function distance(lat1, lon1, lat2, lon2, unit)
Dim theta, dist
theta = lon1 - lon2
dist = sin(deg2rad(lat1)) * sin(deg2rad(lat2)) + cos(deg2rad(lat1)) * cos(deg2rad(lat2)) * cos(deg2rad(theta))
dist = acos(dist)
dist = rad2deg(dist)
distance = dist * 60 * 1.1515
Select Case ucase(unit)
Case "K"
distance = distance * 1.609344
Case "N"
distance = distance * 0.8684
End Select
End Function
'
' This function get the arccos function from arctan function
'
Function acos(rad)
If Abs(rad) <> 1 Then
acos = pi/2 - Atn(rad / Sqr(1 - rad * rad))
ElseIf rad = -1 Then
acos = pi
End If
End function
'
' This function converts decimal degrees to radians
'
Function deg2rad(Deg)
deg2rad = cdbl(Deg * pi / 180)
End Function
'
' This function converts radians to decimal degrees
'
Function rad2deg(Rad)
rad2deg = cdbl(Rad * 180 / pi)
End Function
'Demo
response.write distance(32.9697, -96.80322, 29.46786, -98.53506, "M") & " Miles<br>"
response.write distance(32.9697, -96.80322, 29.46786, -98.53506, "K") & " Kilometers<br>"
response.write distance(32.9697, -96.80322, 29.46786, -98.53506, "N") & " Nautical Miles<br>"
%>
BarrMan
12-21-2005, 08:59 AM
I don't really know how to do it... but i can advice you that:
make a map of the world and define your location point and the destined locations, then everytime someone selects a country it'll match from your location straight with a line to the selected country (if it's a flight, if not tell me and i'll think of something else), and then you can set the line prices:
every 1 cm = 50$(1 cm can be thousands of killometters).
Hope that helps you.
Maybe you can do it with javascript.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.