Zur Navigation

Tabellenspalte berechnen

1 Cutter

Hallo zusammen!

Ich möchte mit dem Script " function addierenA" die Spalte A berechnen.
Aus irgend einem Grund bekomme ich die Sache aber nicht zum laufen.
Kann mir jemand helfen und sagen woran das liegt?

Durch "parseInt" werden nur ganze Zahlen angezegt.
Wie muss ich das ändern, damit Kommazahlen mit zwei Stellen hinter dem Komma angezeigt werden?


<!DOCTYPE html>
<html>
<head>

<meta name="googlebot" content="noindex">
<meta name="robots" content="nofollow">
<meta charset="ISO-8859-1">

<link href="style_demo.css" rel="stylesheet">

<script>
function addierenA()
{
  a = parseInt(document.getElementById('audcad').value);
  b = parseInt(document.getElementById('cadjpy').value);
  c = parseInt(document.getElementById('dkkjpy').value);
  d = parseInt(document.getElementById('eurnzd').value);
  e = parseInt(document.getElementById('gbpeur').value);
  f = parseInt(document.getElementById('jpynok').value);
  g = parseInt(document.getElementById('nzdusd').value);
  h = parseInt(document.getElementById('usddkk').value);
  i = parseInt(document.getElementById('usdzar').value);

  j = a + b + c + d + e + f + g + h + i;

  document.getElementById('sum_spA_un').value = j;

  window.setTimeout("addierenA()", 60000);
}
  window.setTimeout("addierenA()", 60000);
</script>

</head>

<body bgcolor="#FFA700">


<p align="center" style="font-family:Tahoma;font-size:1.5em;color:#AA5500;text-decoration:underline;margin-top:0.3em;">Performance Demo</p>

<div style="margin-top: -3em;">
<a href="javascript: window.history.back();" style="color: #FF0000;font-family:Tahoma;font-size:1.3em;text-decoration: none;margin-left:0.5em;margin-top:-1em;">zurück</a>
</div>

<div style="margin-top:-1.9em;">
<a href="aalive.html"style="color:#FF0000;font-family:Tahoma;font-size:1.3em;text-decoration:none;margin-left:57.5em;">weiter</a>
</div>

<div align="center" style="margin-top: 1em;">
<table>
<thead>
<!-- Zeile 1 -->
<tr>
<td id="g_sum_ob" class="gesamt" colspan="10">0,00</td>
</tr>
<!-- Zeile 2 -->
<tr>
<td id="ob_sum_spA" class="tfoot">0,00</td>
<td id="ob_sum_spB" class="tfoot">0,00</td>
<td id="ob_sum_spC" class="tfoot">0,00</td>
<td id="ob_sum_spD" class="tfoot">0,00</td>
<td id="ob_sum_spE" class="tfoot">0,00</td>
<td id="ob_sum_spF" class="tfoot">0,00</td>
<td id="ob_sum_spG" class="tfoot">0,00</td>
<td id="ob_sum_spH" class="tfoot">0,00</td>
<td id="ob_sum_spI" class="tfoot">0,00</td>
<td id="ob_sum_spJ" class="tfoot">0,00</td>
</tr>
</thead>
<!-- Zeile 3 -->
<tr>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
</tr>
<!-- Zeile 4 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="AUD-CAD.html"target="_parent">AUD-CAD</a></td>
<td class="thead">
<a class="thead1"href="AUD-CHF.html"target="_parent">AUD-CHF</a></td>
<td class="thead">
<a class="thead1"href="AUD-JPY.html"target="_parent">AUD-JPY</a></td>
<td class="thead">
<a class="thead1"href="AUD-NOK.html"target="_parent">AUD-NOK</a></td>
<td class="thead">
<a class="thead1"href="AUD-NZD.html"target="_parent">AUD-NZD</a></td>
<td class="thead">
<a class="thead1"href="AUD-PLN.html"target="_parent">AUD-PLN</a></td>
<td class="thead">
<a class="thead1"href="AUD-SEK.html"target="_parent">AUD-SEK</a></td>
<td class="thead">
<a class="thead1"href="AUD-SGD.html"target="_parent">AUD-SGD</a></td>
<td class="thead">
<a class="thead1"href="AUD-USD.html"target="_parent">AUD-USD</a></td>
<td class="thead">
<a class="thead1"href="CAD-CHF.html"target="_parent">CAD-CHF</a></td>
</tr>
</thead>
<!-- Zeile 5 -->
<tbody>
<tr>
<td id="audcad"class="tbody">74,80</td>
<td id="audchf"class="tbody">12,20</td>
<td id="audjpy"class="tbody">52,10</td>
<td id="audnok"class="tbody">74,80</td>
<td id="audnzd"class="tbody">12,20</td>
<td id="audpln"class="tbody">52,10</td>
<td id="audsek"class="tbody">74,80</td>
<td id="audsgd"class="tbody">12,20</td>
<td id="audusd"class="tbody">52,10</td>
<td id="cadchf"class="tbody">52,10</td>
</tr>
</tbody>
<!-- Zeile 6 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 7 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="CAD-JPY.html"target="_parent">CAD-JPY</a></td>
<td class="thead">
<a class="thead1"href="CAD-PLN.html"target="_parent">CAD-PLN</a></td>
<td class="thead">
<a class="thead1"href="CAD-SGD.html"target="_parent">CAD-SGD</a></td>
<td class="thead">
<a class="thead1"href="CHF-DKK.html"target="_parent">CHF-DKK</a></td>
<td class="thead">
<a class="thead1"href="CHF-JPY.html"target="_parent">CHF-JPY</a></td>
<td class="thead">
<a class="thead1"href="CHF-NOK.html"target="_parent">CHF-NOK</a></td>
<td class="thead">
<a class="thead1"href="CHF-PLN.html"target="_parent">CHF-PLN</a></td>
<td class="thead">
<a class="thead1"href="CHF-SEK.html"target="_parent">CHF-SEK</a></td>
<td class="thead">
<a class="thead1"href="CHF-SGD.html"target="_parent">CHF-SGD</a></td>
<td class="thead">
<a class="thead1"href="CHF-TRY.html"target="_parent">CHF-TRY</a></td>
</tr>
</thead>
<!-- Zeile 8 -->
<tbody>
<tr>
<td id="cadjpy"class="tbody">13,80</td>
<td id="cadpln"class="tbody">-24,20</td>
<td id="cadsgd"class="tbody">-45,10</td>
<td id="chfdkk"class="tbody">13,80</td>
<td id="chfjpy"class="tbody">-24,20</td>
<td id="chfnok"class="tbody">-45,10</td>
<td id="chfpln"class="tbody">13,80</td>
<td id="chfsek"class="tbody">-24,20</td>
<td id="chfsgd"class="tbody">-45,10</td>
<td id="chftry"class="tbody">-45,10</td>
</tr>
<!-- Zeile 9 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
</tbody>
<!-- Zeile 10 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="DKK-JPY.html"target="_parent">DKK-JPY</a></td>
<td class="thead">
<a class="thead1"href="EUR-AUD.html"target="_parent">EUR-AUD</a></td>
<td class="thead">
<a class="thead1"href="EUR-CAD.html"target="_parent">EUR-CAD</a></td>
<td class="thead">
<a class="thead1"href="EUR-CHF.html"target="_parent">EUR-CHF</a></td>
<td class="thead">
<a class="thead1"href="EUR-GBP.html"target="_parent">EUR-GBP</a></td>
<td class="thead">
<a class="thead1"href="EUR-HKD.html"target="_parent">EUR-HKD</a></td>
<td class="thead">
<a class="thead1"href="EUR-HUF.html"target="_parent">EUR-HUF</a></td>
<td class="thead">
<a class="thead1"href="EUR-JPY.html"target="_parent">EUR-JPY</a></td>
<td class="thead">
<a class="thead1"href="EUR-MXN.html"target="_parent">EUR-MXN</a></td>
<td class="thead">
<a class="thead1"href="EUR-NOK.html"target="_parent">EUR-NOK</a></td>
</tr>
</thead>
<!-- Zeile 11 -->
<tbody>
<tr>
<td id="dkkjpy"class="tbody">74,80</td>
<td id="euraud"class="tbody">12,20</td>
<td id="eurcad"class="tbody">52,10</td>
<td id="eurchf"class="tbody">74,80</td>
<td id="eurgbp"class="tbody">12,20</td>
<td id="eurhkd"class="tbody">52,10</td>
<td id="eurhuf"class="tbody">74,80</td>
<td id="eurjpy"class="tbody">12,20</td>
<td id="eurmxn"class="tbody">52,10</td>
<td id="eurnok"class="tbody">52,10</td>
</tr>
</tbody>
<!-- Zeile 12 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 13 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="EUR-NZD.html"target="_parent">EUR-NZD</a></td>
<td class="thead">
<a class="thead1"href="EUR-PLN.html"target="_parent">EUR-PLN</a></td>
<td class="thead">
<a class="thead1"href="EUR-SEK.html"target="_parent">EUR-SEK</a></td>
<td class="thead">
<a class="thead1"href="EUR-SGD.html"target="_parent">EUR-SGD</a></td>
<td class="thead">
<a class="thead1"href="EUR-TRY.html"target="_parent">EUR-TRY</a></td>
<td class="thead">
<a class="thead1"href="EUR-USD.html"target="_parent">EUR-USD</a></td>
<td class="thead">
<a class="thead1"href="GBP-AUD.html"target="_parent">GBP-AUD</a></td>
<td class="thead">
<a class="thead1"href="GBP-CAD.html"target="_parent">GBP-CAD</a></td>
<td class="thead">
<a class="thead1"href="GBP-CHF.html"target="_parent">GBP-CHF</a></td>
<td class="thead">
<a class="thead1"href="GBP-DKK.html"target="_parent">GBP-DKK</a></td>
</tr>
</thead>
<!-- Zeile 14 -->
<tbody>
<tr>
<td id="eurnzd"class="tbody">13,80</td>
<td id="eurpln"class="tbody">-24,20</td>
<td id="eursek"class="tbody">-45,10</td>
<td id="eursgd"class="tbody">13,80</td>
<td id="eurtry"class="tbody">-24,20</td>
<td id="eurusd"class="tbody">-45,10</td>
<td id="gbpaud"class="tbody">13,80</td>
<td id="gbpcad"class="tbody">-24,20</td>
<td id="gbpchf"class="tbody">-45,10</td>
<td id="gbpdkk"class="tbody">-45,10</td>
</tr>
</tbody>
<!-- Zeile 15 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 16 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="GBP-EUR.html"target="_parent">GBP-EUR</a></td>
<td class="thead">
<a class="thead1"href="GBP-JPY.html"target="_parent">GBP-JPY</a></td>
<td class="thead">
<a class="thead1"href="GBP-NOK.html"target="_parent">GBP-NOK</a></td>
<td class="thead">
<a class="thead1"href="GBP-NZD.html"target="_parent">GBP-NZD</a></td>
<td class="thead">
<a class="thead1"href="GBP-PLN.html"target="_parent">GBP-PLN</a></td>
<td class="thead">
<a class="thead1"href="GBP-SEK.html"target="_parent">GBP-SEK</a></td>
<td class="thead">
<a class="thead1"href="GBP-SGD.html"target="_parent">GBP-SGD</a></td>
<td class="thead">
<a class="thead1"href="GBP-USD.html"target="_parent">GBP-USD</a></td>
<td class="thead">
<a class="thead1"href="GBP-ZAR.html"target="_parent">GBP-ZAR</a></td>
<td class="thead">
<a class="thead1"href="HKD-JPY.html"target="_parent">HKD-JPY</a></td>
</tr>
</thead>
<!-- Zeile 17 -->
<tbody>
<tr>
<td id="gbpeur"class="tbody">74,80</td>
<td id="gbpjpy"class="tbody">12,20</td>
<td id="gbpnok"class="tbody">52,10</td>
<td id="gbpnzd"class="tbody">74,80</td>
<td id="gbppln"class="tbody">12,20</td>
<td id="gbpsek"class="tbody">52,10</td>
<td id="gbpsgd"class="tbody">74,80</td>
<td id="gbpusd"class="tbody">12,20</td>
<td id="gbpzar"class="tbody">52,10</td>
<td id="hkdjpy"class="tbody">52,10</td>
</tr>
</tbody>
<!-- Zeile 18 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 19 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="JPY-NOK.html"target="_parent">JPY-NOK</a></td>
<td class="thead">
<a class="thead1"href="MXN-JPY.html"target="_parent">MXN-JPY</a></td>
<td class="thead">
<a class="thead1"href="NOK-DKK.html"target="_parent">NOK-DKK</a></td>
<td class="thead">
<a class="thead1"href="NOK-JPY.html"target="_parent">NOK-JPY</a></td>
<td class="thead">
<a class="thead1"href="NOK-SEK.html"target="_parent">NOK-SEK</a></td>
<td class="thead">
<a class="thead1"href="NZD-AUD.html"target="_parent">NZD-AUD</a></td>
<td class="thead">
<a class="thead1"href="NZD-CAD.html"target="_parent">NZD-CAD</a></td>
<td class="thead">
<a class="thead1"href="NZD-CHF.html"target="_parent">NZD-CHF</a></td>
<td class="thead">
<a class="thead1"href="NZD-JPY.html"target="_parent">NZD-JPY</a></td>
<td class="thead">
<a class="thead1"href="NZD-SGD.html"target="_parent">NZD-SGD</a></td>
</tr>
</thead>
<!-- Zeile 20 -->
<tbody>
<tr>
<td id="jpynok"class="tbody">13,80</td>
<td id="mxnjpy"class="tbody">-24,20</td>
<td id="nokdkk"class="tbody">-45,10</td>
<td id="nokjpy"class="tbody">13,80</td>
<td id="noksek"class="tbody">-24,20</td>
<td id="nzdaud"class="tbody">-45,10</td>
<td id="nzdcad"class="tbody">13,80</td>
<td id="nzdchf"class="tbody">-24,20</td>
<td id="nzdjpy"class="tbody">-45,10</td>
<td id="nzdsgd"class="tbody">-45,10</td>
</tr>
</tbody>
<!-- Zeile 21 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 22 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="NZD-USD.html"target="_parent">NZD-USD</a></td>
<td class="thead">
<a class="thead1"href="PLN-JPY.html"target="_parent">PLN-JPY</a></td>
<td class="thead">
<a class="thead1"href="SEK-JPY.html"target="_parent">SEK-JPY</a></td>
<td class="thead">
<a class="thead1"href="SEK-NOK.html"target="_parent">SEK-NOK</a></td>
<td class="thead">
<a class="thead1"href="SGD-JPY.html"target="_parent">SGD-JPY</a></td>
<td class="thead">
<a class="thead1"href="TRY-JPY.html"target="_parent">TRY-JPY</a></td>
<td class="thead">
<a class="thead1"href="USD-CAD.html"target="_parent">USD-CAD</a></td>
<td class="thead">
<a class="thead1"href="USD-CHF.html"target="_parent">USD-CHF</a></td>
<td class="thead">
<a class="thead1"href="USD-CNH.html"target="_parent">USD-CNH</a></td>
<td class="thead">
<a class="thead1"href="USD-CZK.html"target="_parent">USD-CZK</a></td>
</tr>
</thead>
<!-- Zeile 23 -->
<tbody>
<tr>
<td id="nzdusd"class="tbody">74,80</td>
<td id="plnjpy"class="tbody">12,20</td>
<td id="sekjpy"class="tbody">52,10</td>
<td id="seknok"class="tbody">74,80</td>
<td id="sgdjpy"class="tbody">12,20</td>
<td id="tryjpy"class="tbody">52,10</td>
<td id="usdcad"class="tbody">74,80</td>
<td id="usdchf"class="tbody">12,20</td>
<td id="usdcnh"class="tbody">52,10</td>
<td id="usdczk"class="tbody">52,10</td>
</tr>
</tbody>
<!-- Zeile 24 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 25 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="USD-DKK.html"target="_parent">USD-DKK</a></td>
<td class="thead">
<a class="thead1"href="USD-HUF.html"target="_parent">USD-HUF</a></td>
<td class="thead">
<a class="thead1"href="USD-JPY.html"target="_parent">USD-JPY</a></td>
<td class="thead">
<a class="thead1"href="USD-MXN.html"target="_parent">USD-MXN</a></td>
<td class="thead">
<a class="thead1"href="USD-NOK.html"target="_parent">USD-NOK</a></td>
<td class="thead">
<a class="thead1"href="USD-PLN.html"target="_parent">USD-PLN</a></td>
<td class="thead">
<a class="thead1"href="USD-RUB.html"target="_parent">USD-RUB</a></td>
<td class="thead">
<a class="thead1"href="USD-SEK.html"target="_parent">USD-SEK</a></td>
<td class="thead">
<a class="thead1"href="USD-SGD.html"target="_parent">USD-SGD</a></td>
<td class="thead">
<a class="thead1"href="USD-TRY.html"target="_parent">USD-TRY</a></td>
</tr>
</thead>
<!-- Zeile 26 -->
<tbody>
<tr>
<td id="usddkk"class="tbody">13,80</td>
<td id="usdhuf"class="tbody">-24,20</td>
<td id="usdjpy"class="tbody">-45,10</td>
<td id="usdmxn"class="tbody">13,80</td>
<td id="usdnok"class="tbody">-24,20</td>
<td id="usdpln"class="tbody">-45,10</td>
<td id="usdrub"class="tbody">13,80</td>
<td id="usdsek"class="tbody">-24,20</td>
<td id="usdsgd"class="tbody">-45,10</td>
<td id="usdtry"class="tbody">-45,10</td>
</tr>
</tbody>
<!-- Zeile 27 -->
<tr>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
<td class="leer"></td>
</tr>
<!-- Zeile 28 -->
<thead>
<tr>
<td class="thead">
<a class="thead1"href="USD-ZAR.html"target="_parent">USD-ZAR</a></td>
<td class="thead">
<a class="thead1"href="ZAR-JPY.html"target="_parent">ZAR-JPY</a></td>
<td class="thead">
<a class="thead1"href="DowJones.html"target="_parent">DowJones</a></td>
<td class="thead">
<a class="thead1"href="S_P.html"target="_parent">S_P</a></td>
<td class="thead">
<a class="thead1"href="Nasdaq.html"target="_parent">Nasdaq</a>
</td>
<td class="thead">
<a class="thead1"href="Nikkei.html"target="_parent">Nikkei</a>
</td>
<td class="thead">
<a class="thead1"href="DAX30.html"target="_parent">DAX30</a>
</td>
</tr>
</thead>
<!-- Zeile 29 -->
<tbody>
<tr>
<td id="usdzar"class="tbody">74,80</td>
<td id="zarjpy"class="tbody">12,20</td>
<td id="dowjones"class="tbody">52,10</td>
<td id="s_p"class="tbody">74,80</td>
<td id="nasdaq"class="tbody">12,20</td>
<td id="nikkei"class="tbody">52,10</td>
<td id="dax30"class="tbody">74,80</td>
</tr>
</tbody>
<!-- Zeile 30 -->
<tr>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
<td class="leer0"></td>
</tr>
<!-- Zeile 31 -->
<tfoot>
<tr>
<td id="sum_spA_un" class="tfoot">0,00</td>
<td id="sum_spB_un" class="tfoot">0,00</td>
<td id="sum_spC_un" class="tfoot">0,00</td>
<td id="sum_spD_un" class="tfoot">0,00</td>
<td id="sum_spE_un" class="tfoot">0,00</td>
<td id="sum_spF_un" class="tfoot">0,00</td>
<td id="sum_spG_un" class="tfoot">0,00</td>
<td id="sum_spH_un" class="tfoot">0,00</td>
<td id="sum_spI_un" class="tfoot">0,00</td>
<td id="sum_spJ_un" class="tfoot">0,00</td>
</tr>
<!-- Zeile 32 -->
<tr>
<td id="g_sum_un" class="gesamt" colspan="10">0,00</td>
</tr>
</tfoot>
</table>
</div>
</body>
</html>


Mit freundlichen Grüssen

Cutter

[Edit Jörg: Code in Codeblock eingefügt]

27.11.2016 06:41 | geändert von Jörg: 27.11.2016 15:14

2 Jörg

a = parseInt(document.getElementById('audcad').value);

1. mit value wird nur der Wert eines input ausgelesen. Den Inhalt eines HTML-Elements kann man mit innerHTML ermitteln

2. in JavaScript haben Dezimalzahlen wie auch anderen Programmerisprachen kein Komma, sondern einen Punkt. Man kann das Komma hierzu mithilfe von replace() ersetzen

3. um Strings als Dezimalzahlen zu parsen, kann man parseFloat() verwenden

So sollte es funktionieren:

a = parseFloat(document.getElementById('audcad').innerHTML.replace(',', '.'));

Den Punkt der Summe kannst du am Ende ja wieder mithilfe von replace() umwandeln in ein Komma

27.11.2016 15:22 | geändert: 27.11.2016 15:23

3 Cutter

Hallo Jörg

Vielen Dank für Deine schnell Hilfe.
Das Script für die Berechnung der Tabelle sieht nun so aus.

<script>
function addierenA()
{
a = parseFloat(document.getElementById('audcad').innerHTML.replace(',', '.'));
b = parseFloat(document.getElementById('cadjpy').innerHTML.replace(',', '.'));
c = parseFloat(document.getElementById('dkkjpy').innerHTML.replace(',', '.'));
d = parseFloat(document.getElementById('eurnzd').innerHTML.replace(',', '.'));
e = parseFloat(document.getElementById('gbpeur').innerHTML.replace(',', '.'));
f = parseFloat(document.getElementById('jpynok').innerHTML.replace(',', '.'));
g = parseFloat(document.getElementById('nzdusd').innerHTML.replace(',', '.'));
h = parseFloat(document.getElementById('usddkk').innerHTML.replace(',', '.'));
i = parseFloat(document.getElementById('usdzar').innerHTML.replace(',', '.'));

j = a + b + c + d + e + f + g + h + i;

document.getElementById('sum_spA_un').innerHTML.replace(',', '.') = j;

window.setTimeout("addierenA()", 60000);
}
window.setTimeout("addierenA()", 60000);
</script>

Die Berechnung aber erfolgt leider nicht. Das Script soll eigentlich mit "window.setTimeout("addierenA()", 60000);" gestartet werden.
Die Berechnung sollte jede Minute neu erfolgen.
Ist da vieleicht noch ein Fehler drin?


Gruss Cutter

27.11.2016 17:21

4 Jörg

Die Ersetzung soll ja in j erfolgen, und da du den Punkt wieder durch ein Komma ersetzen möchtest, braucht es ein replace('.', ',') - das erste Argument gibt an, was ersetzt werden soll, das zweite, durch was es ersetzt werden soll.

Vorher müssen wir den Float aber wohl wieder in einen String umwandeln. Und das toFixed(2) sorgt dafür, dass immer zwei Stellen nach dem Punkt ausgegeben werden:

document.getElementById('sum_spA_un').innerHTML = j.toFixed(2).toString().replace('.', ',');

Das Script soll eigentlich mit "window.setTimeout("addierenA()", 60000);" gestartet werden.

Ja, aber auch erst nach 60 Sekunden - ich würde für den ersten Start vielleicht einen niedrigeren Wert wählen, z.B. 2000 (Millisekunden)?

27.11.2016 17:49

1 Forenmitglied fand diesen Beitrag gut

5 Cutter

Hallo Jörg

Vielen Dank für Deine Hilfe. Es funktioniert.
Also ehrlich Jörg, dass hätte ich alleine nicht hinbekommen.
Wieder ein Problem weniger und wieder was dazu gelernt.
Vielen Dank.

Gruss Cutter

27.11.2016 19:07

Beitrag schreiben (als Gast)

Beim Verfassen des Beitrages bitte die Forenregeln beachten.





[BBCode-Hilfe]