Forum Moderators: open

Message Too Old, No Replies

Need Java Script to total prices etc..

         

shawn

7:00 pm on May 29, 2003 (gmt 0)

10+ Year Member



I need either a PHP or java script that will total prices based on different cable packages a customer picks.

For example they pick the base package then add HBO and add on a second receiver for the TV in the bedroom. I would need the script to give them a total based on the packages picked or removed.

If anyone knows of a free script that would be cool too!

Shawn

jatar_k

9:55 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I could see a combo solution. Use javascript to do on page calculations in the form. Maybe put the total in a textbox that updates when they make a new selection. All of the options could be in drop downs with values attributed to them.

Once they are done and submit the form a php script could process the info they provided.

shawn

10:40 pm on May 29, 2003 (gmt 0)

10+ Year Member



Jatar_k

Thank you for your reply - the drop down menu idea is what we were thinking of - we dont even need the information sent anywhere. They simply want the visitor to be able to get an idea of what the packages will cost that they want. If the client wants it mailed to them we will probably submit it via the form handler that we use.

You wouldnt happen to know a site that has a java script available similar to this?

jatar_k

10:59 pm on May 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



As you can see I moved this to the Browsers forum since we are going with javascript. ;)

Well it shouldn't be too difficult to do. The javascript involved is fairly straight forward. You can put the integer/dollar as the value in each option element in the select box. Then add an onChange event handler that calls a function to add the present value in the textbox with the new option value and change the diplayed total.

You are probably better off adding all the values together every time a drop down is changed, then you don't have to check if they changed an already added value.

[edited by: jatar_k at 1:51 am (utc) on May 30, 2003]

liwei

1:33 am on May 30, 2003 (gmt 0)

10+ Year Member



A shopping cart will meet your demand.

Marcia

3:56 am on May 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I've seen a ready to roll JS that did nothing more than calculate prices. It's dim in my memory, since it's been years, but I remember something because it seemed a little useless at the time.

Added: Just checked around a bit, it would probably be listed under a "Calculation" category if there's one available, since it isn't a shopping cart or a catalog.

There's probably something that fits ready made in one of the JS script libraries in the category at ODP - or with doing a search for Javascript (or JS) calculation scripts.