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

  • Home
  • SEARCH
  • 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 8603803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:24:35+00:00 2026-06-12T02:24:35+00:00

I need to write a jQuery / Java function that will take the numbers

  • 0

I need to write a jQuery / Java function that will take the numbers from an AJAX updated value, sanitize it to remove the $, reduce the price by a certain percentage (discPerc) and then make an alert window that notifies the customer of the reduced price.

Here’s what I have so far, I realize I’m not the best coder!

<head>
<script type="text/javascript">
function superSalePrice(discPerc) {
      var optionPrice = $("#productTotal").val();
  var applyDisc = optionPrice * discPerc;
  var rPrice = Math.round(applyDisc * 1) / 1;

  $("tB").click(function() {
  alert("With selected options, final price with discounts is $" + rPrice + "!");
  };
  )
};
</script>
</head>

//THEN the button
<input type="button" id="tB" value="Test Disc. Calc." onclick="superSalePrice(.85);" />

//THEN the option
<td id="productTotal" class="rowElement3"> $3,450.00</td>

I don’t know how to sanitize the value, so that part has not been included yet.

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-12T02:24:36+00:00Added an answer on June 12, 2026 at 2:24 am

    I think you need to make a few changes, try something like this:

    function superSalePrice(discPerc) {
        var optionPrice = $("#productTotal").html(); // Changed from .val()
        var total = parseFloat(optionPrice.replace(/\$/g, "").replace(/,/g, ""));  // Added this
        var applyDisc = optionPrice * discPerc;
        var rPrice = Math.round(applyDisc * 1) / 1;  // Didn't check this
    
        // I'm not sure what the following is for, because you are just binding ANOTHER function every time the button is clicked. Maybe you just want the "alert" line
        $("tB").click(function() {
            alert("With selected options, final price with discounts is $" + rPrice + "!");
        });
    }
    

    Read the comments!

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

Sidebar

Related Questions

I need to write, in JavaScript (I am using jQuery), a function that is
I need to write some jquery which will read what the current value in
I need write a function that will uncheck the old checked boxes with in
I need to write a script in Matlab, which will read some data from
I am attempting to write some jQuery code that will expand a paragraph when
I need to write a split function in JavaScript that splits a string into
I need to write this jQuery function in prototype. How can I convert it?
I am trying to write a jQuery plugin that will have similar functionality to
i have got <div><a class='link' href='index.php' data-container='target'>Load</a></div> <div class='target'></div> i need to write jquery
I need to write a C++ code coverage program that takes in another C++

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.