JS – Round a value

Returns a rounded value function roundit(n) { if(n== »NaN » || typeof n == « undefined » || n == «  » || n == null) {return « n/a »;} else { k = parseFloat(n).toFixed(0); return k;}...

JS – Add a percent sign

Returns a value with percent sign // function addCent(n) { if(n== »NaN » || typeof n == « undefined » || n == «  » || n == null) {return « n/a »;} else {k = parseFloat(n).toFixed(1) + « % »; return k;}...

JS – Create an array with years

Call the function passing a starting Year and it will return an array containing all years from the starting year to the current  // //build a list of years function getYearsList(fromYear) { var arrYears = []; var oDate = new Date(); //add next year in the list if in...

JS – strip parameters from URL

Get the parameter contained in the page Url. Call the function passing the parameter name as: getUrlParameter(« UserName ») // strip parameters from URL function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables =...

JS – Calculate dates difference

Call the function passing 2 dates and it returns the difference in days // function diffdate(d1,d2){ var WNbJours = d2.getTime() – d1.getTime(); return Math.ceil(WNbJours/(1000*60*60*24));...