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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:43:34+00:00 2026-05-22T23:43:34+00:00

js: $(.test).focusout(function(){ var qtdCont = parseInt($(this).val()); if(qtdCont > 0) { var qtdProd = $(.value).val();

  • 0

js:

 $(".test").focusout(function(){
    var qtdCont = parseInt($(this).val());
      if(qtdCont > 0)
      {
         var qtdProd     = $(".value").val();
         var qtdProdInt  = parseInt(qtdProd);
         var qtdProdTot  = qtdProd-qtdCont;
         $(".value").val(qtdProdTot);
      }
 });

Demo: Jsfiddle

i need the subtract only the fist time when he lose the focus.

because if u go’s back and focusout again, the subtraction (obviously) will happen again.

how can i control that ?

thank you.

  • 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-22T23:43:35+00:00Added an answer on May 22, 2026 at 11:43 pm

    Use the data in the dom element:

    $(".test").focusout(function(){
         var qtdCont = parseInt($(this).val());
        if(qtdCont > 0 && $(this).data('done') == undefined)
        {
             var qtdProd     = $(".value").val();
             var qtdProdInt  = parseInt(qtdProd);
             var qtdProdTot  = qtdProd-qtdCont;
             $(".value").val(qtdProdTot);
            $(this).data('done', true);
         }
    });
    

    Fiddle: http://jsfiddle.net/dNEmD/19/

    UPDATE

    $(".test").focusout(function(){
         var qtdCont = parseInt($(this).val());
        if(qtdCont > 0 && 
             ($(this).data('done') == undefined || $(this).data('done') == false))
        {
             var qtdProd     = $(".value").val();
             var qtdProdInt  = parseInt(qtdProd);
             var qtdProdTot  = qtdProd-qtdCont;
             $(".value").val(qtdProdTot);
            $(this).data('done', true);
         }
    });
    
    $(".test").change(function(){ //if value was changed
         $(this).data('done', false);
    });
    

    Fiddle: http://jsfiddle.net/dNEmD/27/

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

Sidebar

Related Questions

// test.js // var testObj = {}; testObj.init = function(){ console.log('google'); } var onload
declare @test varchar(20) set @test = 'VALUE' exec(' select '+@test+' ') This returns: Invalid
This test checks if only one SP ends with Insert, Load, or Save, then
My test file has data like this: 1 2 3 0 1, 2 3,
Test string: the%20matrix%20 How can I delete the last three chars? Using this code
test.php?t=xxx,y=sss This is how the user inputs data to my script. How can I
Test cases for manual testing. Step by step procedure to test this functionality(sticky note)
test.php includes this: echo json_encode( array( array(name=>John,time=>2pm), array(name=>2,time=>1242pm), array(name=>J231ohn,time=>2p213m), )); jQuery : $.get(test.php, function(data)
Test string: $s = convert this: ; $s .= –, —, †, ‡, •,
Test Function def GetTestFile(): sshConn = paramiko.SSHClient() sshConn.load_system_host_keys() sshConn.connect(host, port, usrnm, pwrd) (connin, out,

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.