Eccolo. In effetti avevo messo le altre funzioni poichè a me serviva slo il calcolo della rata.
Cioè, il valore che vorrei poter ottenere in asp è "ImpRata".
Grazie!
codice:
<Script language="JavaScript">
function punta(Numero) {
e =0
PuntatoInv = ""
Lung = Numero.toString().length
for(u = 0; u <= Lung; u++, e++){
PuntatoInv +=Numero.toString().charAt(Lung - u)
if (e == 3 && u < Lung){
PuntatoInv +="."
e = 0
}
}
Puntato = ""
Lung = PuntatoInv.length
for(u = 0; u <= Lung; u++){
Puntato +=PuntatoInv.charAt(Lung - u)
}
return Puntato;
}
function CRata(){
IntMese = (document.forms[0].Int.value / 12);
NRate = (document.forms[0].NAnni.value * 12);
Potenza = (1 + (IntMese/100));
Base = (1 + (IntMese/100));
for(i=1; i < (document.forms[0].NAnni.value * 12); i++){
Potenza = Potenza * Base
}
ImpRata = ((document.forms[0].TotMutuo.value * (IntMese * Potenza)/(Potenza - 1)) *10000);
Tabella = "<Html><Title>- Dettagli del tuo </Title><Body BackGround='sfondo.jpg'><Center><font face='tahoma' size='7' color='red'></font><Center>
<Table Border=0 Width=100%>"
Importo = document.forms[0].TotMutuo.value * 1000000
CapRes = Importo
e = 0
TotInteressi = 0
TotCap = 0
for(i=1; i <= NRate; i++){
Interessi = CapRes * IntMese/100
TotInteressi =TotInteressi + Interessi
QuotaCap = ImpRata - Interessi
TotCap = TotCap + QuotaCap
CapRes = CapRes - QuotaCap;
}
Tabella = Tabella +"<Tr><Td><font face='Tahoma' size=4 color=#FF3333>La rata del tuo sarà di Euro. " + Math.round(ImpRata/10000)/100 + "
Il montante (Capitale + Interessi) sarà di Euro. " + Math.round((ImpRata * NRate)/10000)/100 + "
Gli Interessi saranno di Euro. " + Math.round(TotInteressi/10000)/100 + "</Td></Tr>";
Tabella = Tabella + "</Table></Html>"
if (Tabella != null) {
msgWindow=window.open("","displayWindow",'toolbar=no,width=500,directories=no,status=yes,scrollbars=yes,resize=auto,menubar=no')
msgWindow.document.writeln(Tabella)
msgWindow.document.close()
}
}
function CPiano(){
IntMese = (document.forms[0].Int.value / 12);
NRate = (document.forms[0].NAnni.value * 12);
Potenza = (1 + (IntMese/100));
Base = (1 + (IntMese/100));
for(i=1; i < (document.forms[0].NAnni.value * 12); i++){
Potenza = Potenza * Base
}
ImpRata = ((document.forms[0].TotMutuo.value * (IntMese * Potenza)/(Potenza - 1)) *10000);
Tabella = "<Html><Title> - Piano di Ammortamento</Title><Body BackGround='sfondo.jpg'><Center><font face='tahoma' size='7' color='red'></font></Center>
<font face='Tahoma' size=4 color=#FF3333>Il tuo sarà il seguente:
<Table Border=1 CellSpacing=0><Tr BgColor=#89AE88><Th><Font Color=#FFFFFF>N. Rata</Th><Th><Font Color=#FFFFFF>Quota Interessi</Th><Th><Font Color=#FFFFFF>Quota Capitale</Th><Th><Font Color=#FFFFFF>Importo Rata</Th><Th><Font Color=#FFFFFF>Capitale Residuo</Th></Tr>"
Importo = document.forms[0].TotMutuo.value * 1000000
CapRes = Importo
e = 0
TotInteressi = 0
TotCap = 0
for(i=1; i <= NRate; i++){
Interessi = (CapRes * IntMese/100)
TotInteressi = TotInteressi + Interessi
QuotaCap = (ImpRata - Interessi)
TotCap = TotCap + QuotaCap
CapRes = (CapRes - QuotaCap)
if(e==0){
sTrBg=" BgColor=#BAECB9";
e = 1;
}
else{
sTrBg=" BgColor=#B0E0B0";
e = 0;
}
Tabella = Tabella +"<Tr Align=Right" + sTrBg + "><Td>" + i + "</Td><Td>" + Math.round(Interessi/10000)/100 + "</Td><Td>" + Math.round(QuotaCap/10000)/100 + "</Td><Td>" + Math.round(ImpRata/10000)/100 + "</Td><Td>" + Math.round(CapRes/10000)/100 + "</Td></Tr>";
}
Tabella = Tabella +"<Tr Align=Right BgColor=#89AE88><Td></Td><Td><Font Color=#FFFFFF>[B]" + Math.round(TotInteressi/10000)/100 + "</Td><Td><Font Color=#FFFFFF>[B]" + Math.round(TotCap/10000)/100 + "</Td><Td><Font Color=#FFFFFF>[B]" + Math.round((ImpRata * NRate)/10000)/100 + "</Td><Td> </Td></Tr>";
Tabella = Tabella + "</Table></Html>"
if (Tabella != null) {
msgWindow=window.open("","displayWindow",'toolbar=no,width=600,directories=no,status=yes,scrollbars=yes,resize=auto,menubar=no')
msgWindow.document.writeln(Tabella)
msgWindow.document.close()
}
}
</Script>