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 8866533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:48:31+00:00 2026-06-14T16:48:31+00:00

Basically the problem I’m having is that the second drop-down(bagel_form) is inheriting whatever the

  • 0

Basically the problem I’m having is that the second drop-down(bagel_form) is inheriting whatever the value is in the first drop-down and computing the total based on that.

What I want to happen is to add it’s value to the total based on what IT’S current drop-down is.If the box is checked add to total, if the box is unchecked subtract from total. (based on the drop-down modifier).

I made a fiddle to illustrate the problem, as it’s somewhat confusing.

http://jsfiddle.net/Gqzhq/5/


HTML

<table id="hor-minimalist-b" summary="Breakfast Sponsor">
<th>Pizza</th> <th>Bagel</th>

<tr>
<td><input type="checkbox" name="pizza_form" id="1" value="500"> 
    <select id="my_select">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option></td>

    <td><input type="checkbox" name="bagel_form" id="1" value="200"> 
    <select id="my_select">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option></td>

    </tr>

    </table>
    <div id="total_price">Total:</div>
<input class="total" readonly="readonly"> 

Jquery

var total = 0;
 $('input[name=pizza_form], input[name=bagel_form] ').live('click', function() {
    var current_price = parseInt($(this).attr('value'));
    if($(this).hasClass('checked'))
    {
    $(this).removeClass('checked');
    total -= current_price  ;
    remove_dropdowns(total) ;
    }
    else
    {     
    $(this).addClass('checked');
    total += current_price  ;
    add_dropdowns(total) ;
    }

    function add_dropdowns(total) {
    var quantity = parseInt($('#my_select').val());
    var new_price = parseInt(quantity * total);
    $("input[class='total']").val(new_price); 

    $('select#my_select').change(function() {
    var quantity = parseInt($('#my_select').val());
    var new_price = parseInt(quantity * total);
    $("input[class='total']").val(new_price); 

    });
        }

    function remove_dropdowns(total) {
    var quantity = parseInt($('#my_select').val());
    var new_price = parseInt(quantity * total);
    $("input[class='total']").val(new_price); 

    $('select#my_select').change(function() {
    var quantity = parseInt($('#my_select').val());
    var new_price = parseInt(quantity * total);
    $("input[class='total']").val(new_price); 

    });
        }
 });

​
​

  • 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-14T16:48:33+00:00Added an answer on June 14, 2026 at 4:48 pm

    You’re repeating ids (myselect). If you repeat ids and attempt to select by id, it will just pick the first one.

    Here’s working code:

    http://jsfiddle.net/Gqzhq/10/

    I changed myselect to a class and passed a reference to the current checkbox. From there you can find the next closest .myselect and use that value.

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

Sidebar

Related Questions

Basically my problem is that i've adapted a piece of code found here http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1
Okay guys, basically the problem I'm having is this. I've been assigned to write
I'm having a problem with the SetLength command. It's basically this problem: I work
Basically the problem I have is that in Safari/Chrome it is changing the width
Hi there I am having a problem with my form validation, basically the problem
This is basically the problem that I am facing now, http://jsfiddle.net/NCJeP/ . HTML <nav>
First post, but long time browser :) So here's my problem: Basically I have
I'm quite new to C# and programming in general. Basically my problem is that
Basically my problem is that I need to write a script that automatically creates
Basically the problem is that I'd like to invoke a method in an unreferenced

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.