Archive for the 'Javascripts' Category

jQuery Based Games - Slot Machine


Check out online DEMO

jQuery Stuff


I will be posting jQuery goodies and stuff soon in my blog. All about jQuery, from tutorials to sample applications.

As of now, for those who dont know this awesome javascript framework, i give you a little bit of introduction.

” jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. ”

check out their website in here.

jQuery are known by being lightweight (about 15kb in size), CSS 3 compliant and Cross browser.

Javascript - Auto Currency format in Textbox


Javascript

function auto_currency(id){
	var variable = document.getElementById(id);
	var new_value =  variable.value.replace(/\,/g,"");
	variable.style.textAlign = "right";
	variable.value = digit_grouping(new_value);
}

HTML

<input size="10" onkeyup="auto_currency('coverage')" type="text" id="coverage" name="coverage" />

Javascript Round Number function


function round_number(n, d) {
  n = n - 0;
  if (d == null) d = 2;
  var f = Math.pow(10, d);
  n += Math.pow(10, - (d + 1));
  n = Math.round(n * f) / f;
  n += Math.pow(10, - (d + 1));
  n += '';
  return d == 0 ? n.substring(0, n.indexOf('.')) :  n.substring(0, n.indexOf('.') + d + 1);
}

Example:

price = round_number(4174.315);
alert(price); //Result: 4174.32