Home » jQuery9 March 2015

jQuery: Calculate total price amount on Multiple Checkbox & Radio button selection

Scenario:

I have different checkboxes and radio buttons. The checkboxes and radio buttons have some price value associated with them. Upon checking them I have to calculate the total price and display it in a textbox.

Solution:

We’ll use jQuery for this scenario.

Here’s an example HTML to create checkbox and radio buttons. Checkboxes are made to be multiple selected. Radio buttons are made to be single selected.

Here’s jQuery code to calculate and show total amount based on the selection. “my-activity” is the class name given to the checkboxes and radio buttons.

VIEW DEMO

Form action in the above demo is test.php. I have just printed the post data in it.
Here is the code present in test.php:

VIEW DEMO

Hope this helps. Thanks.

jQuery

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed