Home » jQuery23 March 2015

jQuery: Calculate total price amount on selecting Select & Multi-select box

Scenario:

I have different select box and multiple select boxes. The select dropdown and multi select boxes have some price value associated with them. Upon selecting 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 select and multi-select boxes. Multiple values can be selected from multi-select box. Single value can be selected from the select box (dropdown).

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
  • Burak Şahin

    Thank you!!

  • Anil shah

    thank you so much sir !!!!!!

  • Gulshan Sharma

    When i test this function on local it doesn’t work…why??

  • Gulshan Sharma

    Thank u so much sir…

  • Tahamie Farooqui

    i want to multiply these two values. how can i do it ?