- Fórum WMO
- → Viewing Profile: Posts: Spike Spiegel
Community Stats
- Group Usuários
- Active Posts 2
- Profile Views 841
- Member Title Novato no fórum
- Age Age Unknown
- Birthday Birthday Unknown
-
Sexo
Male
-
Localidade
Bebop
User Tools
Friends
Spike Spiegel hasn't added any friends yet.
Posts I've Made
In Topic: Torpedo Gratis
03/02/2012, 21:02
In Topic: Script De Financiamento
01/02/2012, 14:14
vê c é isso q vc queria:
<script>
function calcula(parcela){
var valor= parseFloat(document.getElementById("avista").value);
var parcela= parseFloat(parcela);
document.getElementById("resultado").value = (valor+50)*parcela;
}
</script>
<font face="Verdana" size="2">
Digite aqui o valor a vista:<br>
<input type="text" id="avista">
<br>
<select name="parcelas" size="1" onchange="calcula(this.value)">
<option value="">Selecione....</option>
<option value="0.2128">Valor 1</option>
<option value="0.1575">Valor 2</option>
<option value="0.1102">Valor 3</option>
<option value="0.1039">Valor 4</option>
</select>
<br>
<hr size="1" color="gray">
Resultado:
<input type="text" id="resultado" readonly>
flws.
Opa, to usando seu script, até fiz algumas personalizações, mas tenho dois problemas:
1 - Estou tendo problemas com o cáculo:
Se eu dividir 140 em 3 vezes, ficaria 48.032000000000004 cada parcela, o que daria 144.096000000000012,
mas se for 999, ficaria 3 de 265.1872 o que daria um total de 795.5616!!!
2 - Não consigo trocar o ponto por vírgula, nem formatar para aparecer os centavos (no resultado).
Veja meu código:
<script>
function calcula(parcela){
var valor= parseFloat(document.getElementById("avista").value);
var parcela= parseFloat(parcela);
document.getElementById("resultado").value = (valor+50)*parcela;
}
</script>
<font face="Verdana" size="2">
Digite aqui o valor do empréstimo:<br>
<!-- Formata dados -->
<script type="text/javascript"><!-- Original: Mario Costa (mariocosta@openlink.com.br) -->
<!-- Bug fix: John Kiernan -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function currencyFormat(fld, milSep, decSep, e) {
var isIE8 = false;
if (window.ActiveXObject) { // IE
// http://www.javascriptkit.com/javatutors/navigator.shtml
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if (ieversion>=8)
{
isIE8 = true;
}
else if (ieversion>=7)
{
}
else if (ieversion>=6)
{
}
else if (ieversion>=5)
{
}
}
}
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (isIE8 /*|| isChrome*/)
{
}
else
{
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true; // Enter
if (whichCode == 8) return true; // Delete (Bug fixed)
key = String.fromCharCode(whichCode); // Get key value from key code
if (strCheck.indexOf(key) == -1) return false; // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
}
// End -->
</script>
<!-- Fim da formatação de dados -->
<input type="text" id="avista"> <!-- onkeypress="return(currencyFormat(this,'',',',event))"> -->
<br>
<select name="parcelas" size="1" onchange="calcula(this.value)">
<option value="">Parcelas</option>
<option value="0.3128">2x com juros de % ao mês.</option>
<option value="0.2528">3x</option>
<option value="0.1575">4x</option>
<option value="0.1102">5x</option>
<option value="0.1039">6x</option>
<option value="0.1039">7x</option>
<option value="0.1039">8x</option>
<option value="0.1039">9x</option>
<option value="0.1039">10x</option>
<option value="0.1039">11x</option>
<option value="0.1039">12x</option>
</select>
<br>
<hr size="1" color="gray">
Resultado:
<input type="text" id="resultado" readonly>
</BODY>
</HTML>Little help please! :S
- Fórum WMO
- → Viewing Profile: Posts: Spike Spiegel
- Privacy Policy
- Regras ·



Postagens