logo
down
shadow

deduce amount issue, not the same value foreach execute


deduce amount issue, not the same value foreach execute

By : Cameron Chang
Date : October 21 2020, 08:10 PM
wish of those help you got rebind issue in your jquery codes, you can simply use unbind to resolve the issue.
hopefully my snippet can help you in some way.. have a nice day!
code :
jQuery("input#barcode").on("keydown",function search(e) {
        if(e.keyCode == 13) {
            var ticketValue = jQuery(this).val();
            console.log("Ticket n°= "+ticketValue);
            var obj = [
                {"id":1, "code":"123", "valeur":20},
                {"id":2, "code":"456", "valeur":30},
                {"id":3, "code":"789", "valeur":15},
                {"id":4, "code":"1011", "valeur":25}
            ];
            var item = obj.find(key => key.code === ticketValue);
            if (item) {
                jQuery('#barcode').prop('disabled', true);
                jQuery("#output, #output-execute-yes, #output-execute-no").css('display', 'block');
                jQuery("#output").html("Ticket ok !"+"<br>"+"Value : "+item.valeur);
                jQuery('#barcode').val('');

                //deduce Amount from total
                
                //use unbind to resolve rebind issue
                jQuery("#output-execute-yes").unbind().click(function() {
                    var newTotal = jQuery("#amount span").text() - item.valeur;
                    jQuery("#amount span").html(newTotal.toFixed(2));
                    jQuery("#output, #output-execute-yes, #output-execute-no").css('display', 'none');
                    jQuery('#barcode').prop('disabled', false);
                });

                jQuery("#output-execute-no").unbind().click(function() {
                    jQuery("#output, #output-execute-yes, #output-execute-no").css('display', 'none');
                    jQuery('#barcode').prop('disabled', false);
                });

            } else {
                jQuery("#output").css('display', 'block');
                jQuery("#output-execute-yes, #output-execute-no").css('display', 'none');
                jQuery("#output").html("Ticket ko !");
                jQuery('#barcode').val('');
            }
        }
    });
h3 {
        text-align: center;
        color: #c81113;
    }
    #barcode {
        padding: 10px;
        border: none;
        border: 1px solid #eaeaea;
        width: 30%;
        font-size: 18px;
        font-weight: bold;
        color: #909090;
    }
    #amount {
        display: inline-block;
        border: 1px solid #eaeaea;
        height: 40px;
        line-height: 40px;
        width: 15%;
        vertical-align: middle;
        text-align: center;
        float: right;
    }
    #amount span {
        font-size: 28px;
        color: #c81113;
        font-weight: bold;
    }
    #output {
        text-align: center;
        font-size: 22px;
        border: 1px solid #7d7d7d;
        padding: 10px;
        color: #fff;
        background-color: #7d7d7d;
        margin-top: 30px;
        border-radius: 5px;
        width: 50%;
        display: block;
        margin-right: auto;
        margin-left: auto;
    }
    #crediter {
        display: inline-block;
        border: 1px solid #eaeaea;
        height: 40px;
        line-height: 40px;
        width: 6%;
        vertical-align: middle;
        text-align: center;
        float: right;
        cursor: pointer;
    }
    #output-execute-yes, #output-execute-no {
        text-align: center;
        font-size: 20px;
        border: 1px solid #c81113;
        padding: 8px;
        color: #fff;
        background-color: #c81113;
        margin-top: 10px;
        border-radius: 5px;
        width: 25%;
        display: block;
        margin-right: auto;
        margin-left: auto;
        cursor: pointer;
    }
    
    div.info {
     padding-top: 43px;
     font-size: 11px;
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Val <input id="barcode" type="text" class="barcode" autofocus="autofocus" onfocus="this.select()"/>
<div id="amount"><span>200.00</span></div>
<div id="output" style="display:none;"></div>
<div id="output-execute-yes" style="display:none;">Yes, I decude</div>
<div id="output-execute-no" style="display:none;">No, I don't deduce</div>

<div class="info">info; try to enter "123", it deduce 20, then enter "123" again, it deduce 40 and not 20 !</div>


Share : facebook icon twitter icon
Why var used in foreach for XmlNode does not deduce real type, only object?

Why var used in foreach for XmlNode does not deduce real type, only object?


By : user6341630
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Let cls be of type XmlNode , ChildNodes is of type XmlNodeList which is defined as
code :
public abstract class XmlNodeList : IEnumerable, IDisposable
Foreach Issue: collection was modified enumeration operation may not execute

Foreach Issue: collection was modified enumeration operation may not execute


By : Ayoub Yoy
Date : March 29 2020, 07:55 AM
With these it helps I believe profileList is bound to profileCollection. So when you call profileCollection.Remove databinding engine will update the profileList.SelectedItems collection to keep in sync.
foreach can't reliably work with collection which is being modified while iterated. You could make a copy of profileList.SelectedItems and iterate over it.
code :
var selectedItems = profileList.SelectedItems
                               .Cast<ProfileControl>()
                               .ToList();
foreach (ProfileControl item in selectedItems) 
{
     profileCollection.Remove(item);
}
How to use iTunes API to find app rank and deduce amount of downloads?

How to use iTunes API to find app rank and deduce amount of downloads?


By : Josh Stevens
Date : March 29 2020, 07:55 AM
will help you I know that it is is not possible to get the App download numbers from any API except by using paid service however I found out that there is a Formula which finds number of downloads on daily basis. , I'm guessing the formula you found should look more like this:
code :
52958 * (rank^-0.944)
rank 10: 6024
rank 100: 685
rank 1000: 77
Foreach array explode amount total amount

Foreach array explode amount total amount


By : dustin-longenecker
Date : March 29 2020, 07:55 AM
With these it helps This is my array i need to add all amounts if they are in together eg 1000|1000 , Split your amt when | appears and calculate the sum using array_sum()
code :
foreach($data as &$array) {
   $array->amt = array_sum(explode('|', $array->amt));
}
Apparent issue when trying to synchronously execute a foreach loop in .NET Core 3.0

Apparent issue when trying to synchronously execute a foreach loop in .NET Core 3.0


By : user3266670
Date : March 29 2020, 07:55 AM
Hope that helps If the order of executing the foreach doesn't matter i suggest something like this:
code :
 Parallel.ForEach(processingModel.breakpoints.Where(b => (b <= processingModel.width)), (breakpoint) =>
            {
                ProcessAsync(processingModel, breakpoint);
            });
Related Posts Related Posts :
  • jQuery target next of the same class in the whole DOM
  • encoding must be a valid encoding error in process encoding
  • How to do a date range to view data from selected date highcharts
  • How do I refactor this composed function with Ramda.js?
  • jQuery to serialize selected option's value, not label
  • Convert object to Chartis.js structure
  • Dynamic import with not bundled file
  • Click handler not firing for elements rendered in Ajax Callback - only in Safari
  • Math.max.apply gives an error CreateListFromArrayLike called on non-object
  • get the parent nodes to a given node in d3 dendogram
  • is-dropdown-submenu-parent makes links unclickable on Opera and Chrome
  • JS: Sum column values and updating result on change
  • Query against nested object keys
  • Fullcalendar getting its parent colspan
  • How to retrieve a dynamic number of elements by id
  • How to access redux variables and functions from deep components
  • Efficiently access Array.prorotype.filter single-item returns
  • PHP var into Javascript
  • How to parse json with javascript/jquery if content matches string
  • How can I make a pyramid based on alphabet?
  • Javascript sorting a csv rows and displaying in table
  • How to get specific data from json from api using ajax. The json looks strange to me
  • react js html5 video not working
  • Javascript Angular 4 Change ngClass from another Component
  • Hide multiple table columns with javascript
  • Convert datetime to ISO Format using moment js
  • Dynamically adjust canvas size depending on content
  • setTimeout function with document on click
  • Need advice on nested Promises.all
  • Google Captcha expiration time
  • Syntax of Javascript TAPE unit test
  • Parse php json to javascript
  • Write to Internet Explorer javascript console with vba in excel
  • 2 Forms with Jquery
  • Why the loop stops right in the middle?
  • filter system for restaurant booking
  • how to add active class in framework nav menu when (add/edit) pages are opened
  • Port a js map in dart
  • How to get value from select using javascript
  • Audio won't be muted with JavaScript - removing audio tags with mutationobserver needed
  • How to include an HTML/Javascript game into reactJS website
  • Convert Nodejs server into node module
  • Strage Vue behaviour. V-if does not watch properly
  • Is it possible to use map/filter/reduce inside a promise by returning the result with Promise.resolve?
  • Does EcmaScript have any rule where whitespace is important for the compiler during parsing
  • How is DOM and Virtual DOM represented in memory?
  • cannot display text onchange select option
  • My gulpfile can edit (change) and delete file, but dont copy new (add) files
  • How do I reset scroll position of paper-dialog-scrollable?
  • Loading unlooped gif-animation several times
  • Strange error from Google API: initializeAutocomplete is not a function
  • Array state variable is not being set during componentWillMount
  • Stop refresh on form submit when using javascript
  • Npm WARN deprecated babel-preset-es2015@6.24.1: Thanks for using Babel: we recommend using babel-preset-env now: please
  • Cant get wheel scroll delta on Firefox
  • Puppeteer with Prompt, ignoring rest of function
  • VueJS Form Input Binding
  • How To Extend mail.Chatter Widget in Javascript Odoo 10
  • How Chk two checkboxes at a time using jQuery
  • Broken "if" statement in JavaScript code…
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org