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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:13:35+00:00 2026-06-14T00:13:35+00:00

I hope someone can help me with the following ‘problem’. Starting with 700 credits,

  • 0

I hope someone can help me with the following ‘problem’.

Starting with 700 credits, the client can buy items that appear in thumbnails(.box)
Adding thumbnails/items costs 25 credits, so when the client has less than 25 left, the add button should be disabled. (This works perfectly by the way)

However in the future I want more simple actions to decrease or increase the credits with diffrent amounts. I made a sample ‘action’ in my example, so when a client clicks the orange square it should decrease with 15. And that’s what causing the trouble. Because I don’t know how to put a limit to the diffrent decreasing values.

For example: if there are 24 credits left, the client can’t buy another box, but should be able to buy something for 15 credits.
(And never credits should never go below zero)

Can anyone help me accomplish this? Keep in mind I would also like to increase and decrease with more actions in the future. Thank you in advance.

JSFIDDLE

Code
JS

var counter = 0;


$("#money").val(250);

$('#purchase').click(function() {
    var box = $('<div class="box"' + (counter) + '><div class="yellow"' + (counter) + '><div class="buy"' + (counter) + '></div></div></div>').appendTo('.container');
    $("#money").val(Number($("#money").val()) - 26);

    if ($("#money").val() < 25) {
        $('#purchase').prop("disabled", true);
    }

    $('.buy').click(function() {
        $(this).fadeOut();
     if ($("#money").val() < 25) {
        $('#purchase').prop("disabled", true);

        $("#money").val(Number($("#money").val()) - 15);
}
    });




});

HTML

<button id="purchase">Add a box </button>
<input id="money"></input>
<div class="container"></div>
  • 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-14T00:13:36+00:00Added an answer on June 14, 2026 at 12:13 am

    Check this out: http://jsfiddle.net/RbnBs/1/

    var counter = 0;
    
    
    $("#money").val(250);
    
    $('#purchase').click(function() {
        if($("#money").val() < 25)
            return; // or alert('not enough money');
    
        var box = $('<div class="box"' + (counter) + '><div class="yellow"' + (counter) + '><div class="buy"' + (counter) + '></div></div></div>').appendTo('.container');
        $("#money").val(Number($("#money").val()) - 25).triggerHandler('change');
    });
    
    $('#money').change(function(){
        $('#purchase').prop("disabled", $(this).val() < 25);
    });
    
    $('.container').on('click', '.buy', function() {
        if($("#money").val() < 15)
            return; // or alert('not enough money');
        $(this).fadeOut();
        $("#money").val(Number($("#money").val()) - 15).triggerHandler('change');;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Google/Bing didnt bring up any solution to my following problem, hope someone can help
Hi hope someone can help, I have the following little problem: Ubuntu server 64bit
I hope someone can help with the following. I'm trying to create a user-specific
Hope someone can help me out with this problem I am having. I just
I am having a JQuery/ASP issue that I hope someone can help me with.
Hi Hope someone can help me. My .net app that connects (via tcp) to
Not quite sure what the problem is, but I hope someone can help me.
hope someone can help me out here. I have the following structure in my
Hope someone can help me. I have used the following tutorial as a guide
I hope someone can help. The following piece of php code (see below) is

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.