The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Radio buttons and a shopping cart
webracin
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Effovex
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
webracin
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 01:36 AM