Forum Moderators: open

Message Too Old, No Replies

How to make form that calculates

forms

         

Oimachi2

5:41 pm on May 24, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



HI there,

I have an auto transport website and would like to make a form that calculates the rates between cities automatically so that the client can get a "real time" automated quote.

Any idea how I can do that or what kind of software I could buy to do this?

Zipper

6:19 pm on May 24, 2008 (gmt 0)

10+ Year Member



You'll probably need an application to calculate the distance between two cities. try googling 'distant calculator <script language>' or you can use google maps API to write your own.

Oimachi2

6:33 pm on May 24, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Actually I will have the price list.

For example, Vancouver to Toronto is $895 ect...

It doesn't work by distance but by cities, and I will know the rates in advance from a chart.

Zipper

8:05 pm on May 24, 2008 (gmt 0)

10+ Year Member



In that case, all you need to do is match up the user entered cities with those on the price list(database/file) and output the corresponding price. does your website have any server side scripting abilities such as PHP, ASP etc?

Oimachi2

10:01 pm on May 24, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi Zipper,

Yes I have PHP installed as I am running a Joomla website.

How do I do this:

"In that case, all you need to do is match up the user entered cities with those on the price list(database/file) and output the corresponding price."

Thanks

Zipper

10:13 am on May 25, 2008 (gmt 0)

10+ Year Member



How do I do this:

I'm not sure whether you are looking for actual code, but let me explain the procedure one more time.

Let's assume your price list contains the following three fields for each record (either in a database or raw file).
from, to, price

Now, in the form, you either list all available cities (drop-downs) or let the users enter the two cities (text fields) which we'll name,
origin, destination

Having the two cities, you can iterate through the price list and check whether both "origin" and "destination" matches the "from" and "to" fields in the price list. If so, you get the corresponding price for that record and display it.

Oh, and since you're running Joomla, you might need to create a module for this.

thecoalman

6:10 am on May 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you want to get started on learning how to do this the php manual on php.net is great place to start. For starters when a user hits the submit button the values in a text field are stored as variables.

[us3.php.net...]

Creating something to do this is not a cut and paste type of thing. You'll need to do some reading.