<!DOCTYPE html>
<html>
<head>

<script>
	function maskIt(w,e,m,r,a){
		// Cancela se o evento for Backspace
			if (!e) var e = window.event
			if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
		// Variáveis da função
			var txt  = (!r) ? w.value.replace(/[^\d]+/gi,'') : w.value.replace(/[^\d]+/gi,'').reverse();
			var mask = (!r) ? m : m.reverse();
			var pre  = (a ) ? a.pre : "";
			var pos  = (a ) ? a.pos : "";
			var ret  = "";
			if(code == 9 || code == 8 || txt.length == mask.replace(/[^#]+/g,'').length) return false;
		// Loop na máscara para aplicar os caracteres
			for(var x=0,y=0, z=mask.length;x<z && y<txt.length;){
			if(mask.charAt(x)!='#'){
			ret += mask.charAt(x); x++; } 
			else {
			ret += txt.charAt(y); y++; x++; } }
		// Retorno da função
			ret = (!r) ? ret : ret.reverse()	
			w.value = pre+ret+pos; }
		// Novo método para o objeto 'String'
			String.prototype.reverse = function(){
			return this.split('').reverse().join(''); 
	};

	function number_format( number, decimals, dec_point, thousands_sep ) {
		var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
		var d = dec_point == undefined ? "," : dec_point;
		var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
		var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
		return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
	}








function calcula() {
	var icms = document.getElementById('icms').value.replace(",",".");
	var valorNota = document.getElementById('valorNota').value.replace(",",".");
	var icmsTotal = document.getElementById('icmsTotal');


	//var total = icms * (valorNota/100);
	var total = icms / valorNota;	
	

	alert(total);
	
	icmsTotal.value = total; 
	icmsTotal.value = icmsTotal.value.replace(".",",");
	
}

	

</script>

</head>
<body>
<form id="form1">
	<input type="text" id="icms" data-thousands="." data-decimal="," data-prefix="R$ " />


	<input type="text" id="valorNota" />

	<input type="text" id="icmsTotal" />

	<input type="button" value="Aqui" onclick="calcula()" />
</form>

</body>


</html>
