Ragazzi buonasera,
sto avendo problemi perchè non riesco proprio a fare in modo che i valori inseriti negli input vengano formattati in 1.234.567,89 anzichè in 1234567,89.

Se ci provo poi il javascript non mi esegue più i calcoli.
Avete idee?

Grazie

codice:
<tbody class="small">                        <tr>
                            <td>RICAVI</td>
                            <td><input type="number" name="ricavi2023" class="input-value"></td>
                            <td><input type="number" name="ricavi2022" class="input-value"></td>
						</tr>
						<tr>	
							<td>+ VAR. RIMANENZE SEMIL. E PRODOTTI</td>
                            <td><input type="number" name="var_riman2023" class="input-value"></td>
                            <td><input type="number" name="var_riman2022" class="input-value"></td>
						</tr>
						<tr>
							<td>+ VAR. VAR. LAV IN CORSO</td>
                            <td><input type="number" name="var_lavcors2023" class="input-value"></td>
                            <td><input type="number" name="var_lavcors2022" class="input-value"></td>
						</tr>
						<tr>	
							<td>+ INCREM. IMM. PER LAVORI INTERNI</td>
                            <td><input type="number" name="var_incrlavint2023" class="input-value"></td>
                            <td><input type="number" name="var_incrlavint2022" class="input-value"></td>
						</tr>
						<tr>	
							<td>+ ALTRI RICAVI E PROVENTI</td>
                            <td><input type="number" name="var_altriricav2023" class="input-value"></td>
                            <td><input type="number" name="var_altriricav2022" class="input-value"></td>
                        </tr>
						<tr></tr>
						<tr>
							<td>= VALORE DELLA PRODUZIONE</td>
							<td><input type="number" name="var_valprod2023" class="input-value" readonly></td>
							<td><input type="number" name="var_valprod2022" class="input-value" readonly></td>
						</tr>
						<tr>	
							<td>-COSTI MATERIE PRIME</td>
                            <td><input type="number" name="var_matprim2023" class="input-value"></td>
                            <td><input type="number" name="var_matprim2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>- SPESE PER SERVIZI</td>
                            <td><input type="number" name="var_spserv2023" class="input-value"></td>
                            <td><input type="number" name="var_spserv2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>- SPESE GODIMENTO BENI TERZI</td>
                            <td><input type="number" name="var_spgodtrz2023" class="input-value"></td>
                            <td><input type="number" name="var_spgodtrz2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>- VARIAZIONE DELLE RIMANENZE</td>
                            <td><input type="number" name="var_varrim2023" class="input-value"></td>
                            <td><input type="number" name="var_varrim2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>- COSTO DEL PERSONALE</td>
                            <td><input type="number" name="var_pers2023" class="input-value"></td>
                            <td><input type="number" name="var_pers2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>- ONERI DIVERSI DI GESTIONE</td>
                            <td><input type="number" name="var_ondiv2023" class="input-value"></td>
                            <td><input type="number" name="var_ondiv2022" class="input-value"></td>
                        </tr>
						<tr>	
							<td>= MARGINE OPERATIVO LORDO (MOL/EBITDA)</td>
							<td><input type="number" name="var_mol2023" class="input-value" readonly></td>
							<td><input type="number" name="var_mol2022" class="input-value" readonly></td>
						</tr>
						<tr><td></td></tr>
						<tr>	
							<td>UTILE DI ESERCIZIO</td>
                            <td><input type="number" name="var_utile2023" class="input-value"></td>
                            <td><input type="number" name="var_utile2022" class="input-value"></td>
                        </tr>
						<tr><td></td></tr>
						<tr>	
							<td>PATRIMONIO NETTO</td>
                            <td><input type="number" name="var_patr2023" class="input-value"></td>
                            <td><input type="number" name="var_patr2022" class="input-value"></td>
                        </tr>
						<tr><td><br></td></tr>
						<tr>
							<th></th>
							<th>2023</th>
						</tr>
						<tr>	
							<td>IMPOSTE CORRENTI</td>
                            <td><input type="number" name="var_impcorr2023" class="input-value"></td>
                        </tr>
						<tr>	
							<td>INTERESSI ED ONERI FINANZIARI</td>
                            <td><input type="number" name="var_intonfin2023" class="input-value"></td>
                        </tr>
						<tr><td><br></td></tr>
						<tr>	
							<td>DEBITI VERSO BANCHE</td>
                            <td><input type="number" name="var_dbbnc2023" class="input-value"></td>
                        </tr>
						<tr>	
							<td>OBBLIGAZIONI</td>
                            <td><input type="number" name="var_obb2023" class="input-value"></td>
                        </tr>
						<tr>	
							<td>DEBITI VERSO ALTRI FINANZIATORI</td>
                            <td><input type="number" name="var_altrifin2023" class="input-value"></td>
                        </tr>
						<tr>	
							<td>DEBITI VERSO SOCI</td>
                            <td><input type="number" name="var_dbsoc2023" class="input-value"></td>
                        </tr>
						<tr>	
							<td>DISPONIBILITA' LIQUIDE</td>
                            <td><input type="number" name="var_displiq2023" class="input-value"></td>
                        </tr>
                        <!-- Altre righe come sopra -->
                    </tbody>
                </table>
				<table class="table table-bordered table-striped">
					<tr>
                        <th>MOL (EBITDA)</th>
                        <td><input type="number" name="mol_ebitda" class="input-value" readonly></td>
                        <th>PFN</th>
                        <td><input type="number" name="pfn" class="input-value" readonly></td>
                    </tr>
                    <tr><td></td></tr>
                    <tr>
                        <th>DSCR INIZIALE</th>
                        <td><input type="number" name="dscr_iniz" class="input-value" readonly></td>
						<th>DSCR FINALE</th>
                        <td><input type="number" name="dscr_fin" class="input-value" readonly></td>
                        <th>PFN/MOL</th>
                        <td><input type="number" name="pfn_mol" class="input-value"readonly></td>    
                    </tr>
				</table>
				<table class="table table-bordered table-striped">
					<tr>
                        <th>IMPORTO MASSIMO DELLA RICHIESTA</th>
                        <td><input type="number" name="imp_max" class="input-value" readonly></td>
                    </tr>
				</table>
				<script>
					document.addEventListener('DOMContentLoaded', function() {
						const inputs = document.querySelectorAll('.input-value');
						inputs.forEach(input => {
							input.addEventListener('input', calculateValues);
						});


						function calculateValues(targetDSCR = 0.85) {
							// Recupera i valori dai campi di input
							const ricavi2023 = parseFloat(document.querySelector('[name="ricavi2023"]').value) || 0;
							const varRiman2023 = parseFloat(document.querySelector('[name="var_riman2023"]').value) || 0;
							const varLavcors2023 = parseFloat(document.querySelector('[name="var_lavcors2023"]').value) || 0;
							const varIncrlavint2023 = parseFloat(document.querySelector('[name="var_incrlavint2023"]').value) || 0;
							const varAltriricav2023 = parseFloat(document.querySelector('[name="var_altriricav2023"]').value) || 0;


							// Calcolo Valore della Produzione
							const valoreProduzione2023 = ricavi2023 + varRiman2023 + varLavcors2023 + varIncrlavint2023 + varAltriricav2023;
							document.querySelector('[name="var_valprod2023"]').value = valoreProduzione2023.toFixed(2);


							// Calcolo Margine Operativo Lordo (MOL/EBITDA)
							const varMatprim2023 = parseFloat(document.querySelector('[name="var_matprim2023"]').value) || 0;
							const varSpserv2023 = parseFloat(document.querySelector('[name="var_spserv2023"]').value) || 0;
							const varSpgodtrz2023 = parseFloat(document.querySelector('[name="var_spgodtrz2023"]').value) || 0;
							const varVarrim2023 = parseFloat(document.querySelector('[name="var_varrim2023"]').value) || 0;
							const varPers2023 = parseFloat(document.querySelector('[name="var_pers2023"]').value) || 0;
							const varondiv2023 = parseFloat(document.querySelector('[name="var_ondiv2023"]').value) || 0;
							const mol2023 = valoreProduzione2023 - (varMatprim2023 + varSpserv2023 + varSpgodtrz2023 + varVarrim2023 + varPers2023 + varondiv2023);
							document.querySelector('[name="var_mol2023"]').value = mol2023.toFixed(2);
							document.querySelector('[name="mol_ebitda"]').value = mol2023.toFixed(2);


							// Calcolo PFN
							const varDbbnc2023 = parseFloat(document.querySelector('[name="var_dbbnc2023"]').value) || 0;
							const varobb2023 = parseFloat(document.querySelector('[name="var_obb2023"]').value) || 0;
							const varaltrifin2023 = parseFloat(document.querySelector('[name="var_altrifin2023"]').value) || 0;
							const varDbsoc2023 = parseFloat(document.querySelector('[name="var_dbsoc2023"]').value) || 0;
							const varDispliq2023 = parseFloat(document.querySelector('[name="var_displiq2023"]').value) || 0;
							const pfn2023 = varDbbnc2023 + varobb2023 + varaltrifin2023 + varDbsoc2023 - varDispliq2023;
							document.querySelector('[name="pfn"]').value = pfn2023.toFixed(2);


							// Calcolo PFN/MOL
							const pfnMol2023 = mol2023 !== 0 ? (pfn2023 / mol2023) : 0;
							document.querySelector('[name="pfn_mol"]').value = pfnMol2023.toFixed(2);


							// Calcolo importomassimorichiesta
							const imposteCorrenti2023 = parseFloat(document.querySelector('[name="var_impcorr2023"]').value) || 0;
							const interessiOneriFinanziari2023 = parseFloat(document.querySelector('[name="var_intonfin2023"]').value) || 0;
							const f3_b21 = mol2023 - imposteCorrenti2023;
							console.log("f3-b21:", f3_b21);
							const zeroottantacinqueXB22 = 0.85 * interessiOneriFinanziari2023;
							console.log("zeroottantacinqueXB22:", zeroottantacinqueXB22);
							const f3_b21_meno_zeroottantacinqueXB22 = f3_b21 - zeroottantacinqueXB22;
							console.log("f3_b21_meno_zeroottantacinqueXB22:", f3_b21_meno_zeroottantacinqueXB22);
							const f3_b21_meno_zeroottantacinqueXB22_per5 = f3_b21_meno_zeroottantacinqueXB22 * 5;
							console.log("f3_b21_meno_zeroottantacinqueXB22_per5:", f3_b21_meno_zeroottantacinqueXB22_per5);
							const f3_b21_meno_zeroottantacinqueXB22_per5_diviso085 = f3_b21_meno_zeroottantacinqueXB22_per5 / 0.85;
							console.log("f3_b21_meno_zeroottantacinqueXB22_per5_diviso085:", f3_b21_meno_zeroottantacinqueXB22_per5_diviso085);
							const B24_B25_B26_B27_menoB28 = varDbbnc2023 + varobb2023 + varaltrifin2023 + varDbsoc2023 - varDispliq2023;
							console.log("B24_B25_B26_B27_menoB28:", B24_B25_B26_B27_menoB28);


							// Assegna il calcolo a importoMassimoRichiesta senza dichiararla nuovamente
							let importoMassimoRichiesta = f3_b21_meno_zeroottantacinqueXB22_per5_diviso085 - B24_B25_B26_B27_menoB28;
							document.querySelector('[name="imp_max"]').value = importoMassimoRichiesta.toFixed(2);
							
							// Calcolo DSCR iniziale
							const B24_B25_B26_B27_menoB28_diviso5 = B24_B25_B26_B27_menoB28 / 5;
							const B24_B25_B26_B27_menoB28_diviso5_B22 = B24_B25_B26_B27_menoB28_diviso5 + interessiOneriFinanziari2023;
							const dscriniz = f3_b21 / B24_B25_B26_B27_menoB28_diviso5_B22;
							document.querySelector('[name="dscr_iniz"]').value = dscriniz.toFixed(2);
							
							// Calcolo DSCR finale
							const B24_B25_B26_B27_F10_menoB28_diviso5 = (B24_B25_B26_B27_menoB28 +  importoMassimoRichiesta) / 5;
							const B24_B25_B26_B27_F10_menoB28_diviso5_B22 = B24_B25_B26_B27_F10_menoB28_diviso5 + interessiOneriFinanziari2023;
							const dscrfin = f3_b21 / B24_B25_B26_B27_F10_menoB28_diviso5_B22;
							document.querySelector('[name="dscr_fin"]').value = dscrfin.toFixed(2);
						}


						// Esegui calcolo iniziale con DSCR target di 0.85
						calculateValues(0.85);
					});
				</script>