Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:49:23+00:00 2026-06-04T03:49:23+00:00

I have a dropdown list populated by mysql working perfectly, I also have it

  • 0

I have a dropdown list populated by mysql working perfectly, I also have it displaying the price set by mysql, so far i’m happy.

What the issue is as it’s a multiple dropdown list, it will only display what is chosen first, if I pick 2 or more selections, only the first price is shown.

My second issue is I want the prices to add up i.e. 1st Selection’s price is £1.99, 2nd Selection’s price is £2.99 so the total should be £4.98

Finally once i have all this working, I want to continue this onto the 2nd / 3rd / 4th dropdown boxes so that all the boxes add up giving me a combined total.

Here’s my html code to show you what i’m using:

<form method="post" action="" name="form1">
  <? 
  include 'classes.php';
  $query="SELECT * FROM Sex_Table";
  $result=mysql_query($query);
  ?>
  <select data-placeholder="Your Favorite Football Team"  class="chzn-select" multiple tabindex="6" id="Sexdiv" name="Sexdiv" style="width: 300px;" onChange="getClothing(this.value),changePrice()">
  <option>Select Colour Type</option>
  <? while($row=mysql_fetch_array($result)) { ?>
  <option value=<?=$row['ID']?> sex_price="<?=$row['Price']?>"><?=$row['Sex_Name']?>&nbsp;(£<?=$row['Price']?>)</option>
  <? } ?>
  </select><br /><br />
  <p id="Clothingdiv">
  <select style="width: 300px;" name="Clothing" disabled='disabled'>
  <option>Select Sex First</option>
  </select>
  </p><br />
  <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true}); </script>
  </form>

and here’s my js:

function changePrice() {
 var sex_price = $("option:selected").attr("sex_price");
 $("#price_div").html("Price = £" + sex_price);
}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:49:25+00:00Added an answer on June 4, 2026 at 3:49 am

    Below is an example of what you’re trying to do, I’ve given each select element I want to calculate the total for a class so that they are not mixed up with other elements.

    jQuery

    <script>
    $(document).ready(function() {
        $('.calculate').change(function() {
            var total = 0;
            $('.calculate').each(function() {
                if($(this).val() != 0) {
                    total += parseFloat($(this).val());
                }
            });
            $('#total').text('£' + total.toFixed(2));
        });
    });
    </script>
    

    HTML

    <select class="calculate" name="select-1">
        <option value="0">Please Select</option>
        <option value="1.99">£1.99</option>
        <option value="2.99">£2.99</option>
    </select>
    
    <select class="calculate" name="select-2">
        <option value="0">Please Select</option>
        <option value="1.99">£1.99</option>
        <option value="2.99">£2.99</option>
    </select>
    
    <select class="calculate" name="select-3">
        <option value="0">Please Select</option>
        <option value="1.99">£1.99</option>
        <option value="2.99">£2.99</option>
    </select>
    
    <span id="total">£0</span>
    

    This will update the contents of total with the total price of each select element with class calculate when one of them is changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdown list that is currently populated from a result set of
I have a populated dropdown list from mysql on one page. What code should
I have a bound dropdown list populated with a table of names through a
I have created a populated dropdown list in HTML. When the two dropdowns have
I have a dropdown list (FK) which I would like to set and display
Basically, I have populated a dropdown list using php from a database on a
I have a dropdown box which is populated from a mysql table. When viewing
I have a dropdown list that is populated when the page loads, like this:
I have a dropdown input field (list of options populated from the database), is
I have a dropdown list which is populated via a jquery ajax call when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.