This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `paises` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`iso` char(2) DEFAULT NULL, | |
`nombre` varchar(80) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; | |
INSERT INTO `paises` VALUES(1, 'AF', 'Afganistán'); | |
INSERT INTO `paises` VALUES(2, 'AX', 'Islas Gland'); | |
INSERT INTO `paises` VALUES(3, 'AL', 'Albania'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function number_format(number, decimals, dec_point, thousands_point) { | |
if (number == null || !isFinite(number)) { | |
throw new TypeError("number is not valid"); | |
} | |
if (!decimals) { | |
var len = number.toString().split('.').length; | |
decimals = len > 1 ? len : 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function number_format(number, decimals, decPoint, thousandsSep){ | |
decimals = decimals || 0; | |
number = parseFloat(number); | |
if(!decPoint || !thousandsSep){ | |
decPoint = '.'; | |
thousandsSep = ','; | |
} | |
var roundedNumber = Math.round( Math.abs( number ) * ('1e' + decimals) ) + ''; |