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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:39:09+00:00 2026-06-05T17:39:09+00:00

I have a function which takes two arguments, the ID of an item (wine)

  • 0

I have a function which takes two arguments, the ID of an item (wine) and the quantity of bottles ordered.

The order is built up in a dynamic jquery table.

The logic is that if the user buys more than 3 bottles a discount is applied, and a row showing the discount to the wine is added. If they change the value to 3 or more, and then drop the value to below 3 I want the row showing the discount to be removed.

Why does this not work? The alert is firing, so I guess it is an error with the remove() line.

            function UpdateWineDiscount(id, qty) {
            // Does discount row already exist?
            if ($("#trTable tr > td:contains('D" + id + "')").length) {
                // If discount row exists and qty is now below 3, remove it
                if (qty < 3) {
                    $("D" + id).remove();
                    alert("remove");
                };
            } else {
                // Is qty >= 3?
                if (qty >= 3) {
                    // Add discount row
                    var newRow = $("<tr id='D" + id + "' style='color:red'> <td class='drinkID' style='display:none'>D" + id + "</td> <td class='drinkName'>Wine Discount</td>  <td></td>  <td></td>  <td></td>  <td></td>  <td class='drinkTotal'>-1</td>  </tr>");
                    $("#trTable").append(newRow);
                } else {
                    // Update discount value
                };
            };
        }
  • 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-05T17:39:10+00:00Added an answer on June 5, 2026 at 5:39 pm

    Your code is a little off in order to remove an element by id it needs to have a # in front:

    $("#D" + id).remove();

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

Sidebar

Related Questions

I have written a function in python that takes two arguments one of which
I have two Python functions, both of which take variable arguments in their function
I have a function which takes in two parameters, and returns one or the
I have a merge function which takes time O(log n) to combine two trees
I have a ColdFusion function foo which takes three args, and the second two
I have a list A , and a function f which takes an item
Please help me writing a function which takes two arguments: a list of ints
I have two functions, one which parses all the arguments sent to the function
I have a SQL function called get_forecast_history(integer,integer) that takes two arguments, a month and
I want to create a function which takes two arguments A String value (name)

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.