Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery script issue on different browser
    primarykey
    data
    text
    <p>I have an issue with the following script, it basically turn the colour of the entered digits from black to red if the number entered is >100, or the total of the entry is >100.</p> <p>The first part is fine but since I don't have control over the total entry, as it is being calculated at the back end (.confirmit-as-sum-field), I can only grab the text being displayed and see if it's over the limit. This works fine in Chrome but not IE, e.g. IE seems to delay the colour changes, there are two text boxes, if the first one is 70, 2nd one is 40 the total will be 110, the total will still be in black font, it will turn red until I have added one more digit in 2nd box to 400, which makes the total to be 470. And it will continue to be in red if i add more digits to either boxes. However if I bring the total to be below 100 for the first time, the colour of the font will still be in red, it will only go to black if i adjust the digit to another number below the 100 mark the second time.</p> <p>Here is the script, not sure if you could see any browser specific issues here, or alternative ways I can try:</p> <pre><code>//flag numbers over 100% $('.numberinput').each(function() { $(this).keyup(function(){ if($(this).val()&gt;100){$(this).css('color','red');} else{$(this).css('color','black');} //flag total over 100% var sum = $('.confirmit-as-sum-field').text(); if(parseInt(sum) &gt;100){$('.confirmit-as-sum-field').css('color','red')} else{$('.confirmit-as-sum-field').css('color','black')} }); }); </code></pre> <p>Many thanks, Roy</p> <hr> <p>Here is the backend bits, not sure if that's any help:</p> <pre><code> var args = ["wix-components","wix-numeric","wix-auto-sum","wix-focus-first","yui-later"], yui3 = YUI({ loadErrorFn: showFieldsets, groups: { wix: { base: '/cf_clientutil/wix/', combine: false, modules: {"confirmit-cblib":{"fullpath":"/cf_clientutil/scripts/cblib-min.js?v=2891_P19c","requires":["dom","event","node","oop"]},"confirmit-dedchain":{"fullpath":"/cf_clientutil/scripts/dedchain-min.js?v=2891_P19c","requires":["confirmit-cblib"]},"wix":{"path":"wix-min.js?v=2891_P19c","requires":["node"]},"wix-components":{"path":"wix-components-min.js?v=2891_P19c","requires":["wix","confirmit-cblib","plugin","base","selector-css3"]},"wix-slider-base":{"path":"slider-base-min.js","requires":["wix","event-resize"]},"wix-numeric":{"path":"numeric-min.js?v=2891_P19c","requires":null},"wix-auto-sum":{"path":"auto-sum-min.js?v=2891_P19c","requires":null},"wix-focus-first":{"path":"wix-focus-first-min.js?v=2891_P19c","requires":["wix"]}} } }, allowRollup: false, filter: '', comboBase: '/wix/combo.aspx?', combine: true }); args.push( function(Y) { var wix = Y.WixInstance = new Y.Wix( {"formId":"ctlform","debug":false,"capi":false,"offline":false,"defaultLanguage":9} ); Y.WixInstance.addComponent({"type":"Numeric","hostId":"ps1_1","fieldsetId":"fieldset_ps1","digits":3,"decimals":0,"thousandSep":"%2C","decSep":"."}); Y.WixInstance.addComponent({"type":"Numeric","hostId":"ps1_2","fieldsetId":"fieldset_ps1","digits":3,"decimals":0,"thousandSep":"%2C","decSep":"."}); Y.WixInstance.addComponent({"type":"AutoSum","fieldsetId":"fieldset_ps1","questionType":"multi","inputPrefix":"","inputSuffix":"%","scale":0,"sumLabel":"Total"}); window.wix = Y.WixInstance; window.wix.Y = Y; window.onerror = Y.WixInstance.handleError; Y.WixInstance.fire('ready'); } ); yui3.use.apply(yui3, args); } else { showFieldsets(); } })(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload