Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Looking for Instant price quote script for my site

    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.

  2. #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    What is the calculation for it? ex. result = ((value1*value2-value3)/350)*value4.

  3. #3
    New Coder
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question

    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.


  4. #4
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    I'm not sure if i'm right, but i looked at w3schools and i got an idea for you:
    Code:
    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.

  5. #5
    New Coder
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  6. #6
    New Coder
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    60
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.

    Code:
    <%
                                                                 
    '  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>"
    
    %>
    Last edited by Pinto7; Dec 17th, 2005 at 06:24 PM.

  7. #7
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    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.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •