Radio buttons and a shopping cart |
Radio buttons and a shopping cart |
webracin |
Mar 30 2007, 01:11 AM
Post
#1
|
Group: Members Posts: 2 Joined: 30-March 07 Member No.: 2,366 |
Hi I am trying to create a registration form for a car club meet.
What I would like to do is to use radio buttons on the form, but would also like to have each button correspond to a dollar value, and then it show a total at the bottom of the page above the submit button. There are many options for different packages, T-shirts, Meals, etc, and I would like to add each selection and provide a total before they submit their registration. If you need to see what the form looks like, its at www.bransongpmeet.com/registration.html Any help would be appreciated Thanks Chris |
Effovex |
Mar 30 2007, 03:20 AM
Post
#2
|
Serious Coder Group: Members Posts: 251 Joined: 6-January 07 From: Sherbrooke, Qc, Canada Member No.: 1,477 |
First of all: your radio buttons are incorrectly coded (I can select all of them which doesn't seem to be the intended purpose.) You need to give each radio button in a group the same name with a different value.
As for how to calculate the total, from what I understand you wish to have a total automatically update whenever an item within the form is changed. To do this, you need Javascript, which isn't 100% reliable - once you submit, you should have a second page to confirm the total from a server-side calculation. However, nothing prevents you from having a javascript-based calculator IN ADDITION to the server side calculator. So how to do it: the easiest way is to simply add a onchange event on every important form element, and to execute a javascript function that takes the value of every relevant form element and adds them up, and then writes that total wherever you want it to appear. This isn't very elegant but it does the job and it's rather easy to program. Of course, if you've never programmed, it may seem rather daunting, but there are plenty of decent tutorials to go around and this should be very straightforward without much possibility for compatibility problems. |
webracin |
Mar 30 2007, 08:49 AM
Post
#3
|
Group: Members Posts: 2 Joined: 30-March 07 Member No.: 2,366 |
Thanks Effovex,
Yes I knew the radio buttons were incorrect...I just threw that page together, and forgot to group them, but have them fixed for the new upload. I was hoping to get the sudo shopping cart added before I did it, but it is distracting when looking for help, so its uploading now....I will upload the "cart" when I finish it.... Thanks again Chris |
Lo-Fi Version | Time is now: 26th April 2024 - 01:36 AM |