I think this should be simple...

Status
Not open for further replies.

Phre0nBurn

I <3 JAILBAIT!
Mar 20, 2007
686
9
0
Phoenix
I need to make a form that allows a live output based on the selections.

Let me explain...
Ill use a simple example here, although what I need will have about 6 options.

Within the page, there will be options with check boxes next to them
ie

Base: $100
[ ] Option1: $50
[x] Option2: $75

Your Price: $175

You see what I mean? I need a simple form that starts with a base number, then adds the corresponding number of each selection made to that number, and shows the total sum where i need it.

It seems simple, but I could be wrong, as I suck at this.

Anyone want to bestow upon me some of their vast and uber awesome knowledge?
:)
 


You're probably looking at some basic javascript. You'd have a variable that held the base value, and a function that went to each of the form elements and added the values from them. It's been a while since I've built that sort of thing so I can't tell you exactly how to do it but that should get you going.

Unless you need to talk to the server and back, to get prices that change rapidly, in which case you'll want something more ajaxy.
 
Yea, no server side needed. It's just so I can show my customers what their cost for product would be based on variables they select... I hate that I cant figure things like this out, lol, it seems like it should be so simple...

Anyways, thanks, Ill Goog some of that stuff and see what I can find...
 
Javascript for that should be easy.
Just make the button "Calculate" trigger your javascript.
Then it is just adding different values..

::emp::
 
Dude, that's so close...!

I swapped them over to check boxes, but I can't get it to add multiple options at the same time...

Like if base is 400
Opt1 100
Opt2 200
Opt3 300

And they select Opt1 and Opt3, it won't calculate it right...
Do you know a simple way of accomplishing that?

Thanks though man!

(Note: now that I look at this, I understand everything the code does, its surprisingly simple... I dunno why I have such a hard time learning this shit...)
 
So much love on this thread, lol...

If you want to add on a level of sophistication to what you're trying to do, you can implement some simple AJAX to do essentially the same thing. The advantage of the AJAX script route is that you can write to a shopping cart db in real time.

Anyways, it's definitely worth your time to learn the basics of Javascript since so many things can be implemented using it.
 
Houdas - THANK YOU!!!!
You F'n rock dude.

I just picture how drunk you guys will all be when someone invents an actual way to send real beer in real time to someone.
:)

Dave- I didn't even know what AJAX was until I started toying with Thickbox (which I couldn't get to work for the life of me) 2 days ago. lol

I have a lot of books + videos on PHP, Java, etc., I just have to find the time to sit down and learn it.

I don't need shopping cart functionality for this particular site, but I will need it in the future for a project I am working on... So maybe I'll look a little more into AJAX, and of course, PHP
 
Status
Not open for further replies.