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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:41:14+00:00 2026-05-26T13:41:14+00:00

I have the following script: <script language=javascript> function process(v){ var value = parseInt(document.getElementById(‘v’).value); value+=v;

  • 0

I have the following script:

<script language=javascript>
    function process(v){
        var value = parseInt(document.getElementById('v').value);
        value+=v;
        document.getElementById('v').value = value;
    }
</script>


<input type=test size=10 id='v' name='v' value='3'>
<input type=button value='-' onclick='javascript:process(-1)'>
<a id="v" href="#" onclick='javascript:process(-1)'>minus</a>

If you click the button, it will deduct 1 from the total amount (3). The same applies for the minus-link. Now this all works great.

The problem is that I want to allow each one to deduct 1, just one time. Without disabling the button/link.

Example what I need:
So I click the button: 3 -> 2.
Now I click the button again, nothing will happen 2 stays 2.
Now I click the minus-link, 2 -> 1.
Clicking the link again, nothing will happen 1 stays 1

This can all be mixed of course. The main thing is, they each are allowed to do the -1 just one time (the first time clicked upon).

How to do this?

Kind regards,
Maurice

  • 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-05-26T13:41:14+00:00Added an answer on May 26, 2026 at 1:41 pm

    Since this question is tagged under jQuery, I provide you a way do do it in jQuery! Using this could help you in the long run to get a cleaner code and to fix future problems like this 😉

    Demo: http://jsfiddle.net/NtHwN/4/

    <input size=10 id="sum" value="3">
    <input class="minus" type=button value="-">
    <a class="minus" href="#">minus</a>
    
    $(document).ready(function() {
        $(".minus").one("click", function(){
            var value = parseInt($("#sum").val());
            $("#sum").val(value -1);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <script language=javascript type=text/javascript> function readCookie(name) { var nameEQ =
I have the following in a jsp page; <script language=javascript> function ClickMe_Click(){ $.ajax({ type:
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I
I have the following script: Timer=0; function countdown(auctionid){ var auctions; var divs; Timer=Timer+1; if((Timer%10==0)||(Timer==1)){
So I have code like this: <script language=javascript> $(function(){ function hellothere(strng){ showalert(strng); } function
i have following lines included at the bottom of my index.php: <script type=text/javascript language=javascript
I have the following script, where the first and third document.writeline are static and
I have following two tables and a script having a function includePage() . Table
I have the following script. It replaces all instances of @lookFor with @replaceWith in

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.