Moin, ich habe ein einfaches JavaScript, dass auf Contentseiten funktioniert, aber auf einer Produktseite keinen Wert mehr ausgibt. Jemand eine Idee, woran das liegen könnte? Code: <div class="row row-60"> <div class="col-md-12"> <script type="text/javascript"> function rechne() { var eingabe=parseFloat("0"+document.getElementById("ein").value); var aus01=(Math.ceil(1.05*eingabe/2)).toFixed(0)+" Profile"; document.getElementById("out01").firstChild.data=aus01; } </script> <p style="font-weight:bold; color:#4d4d4d;"> Raumumfang (m) </p> <form action="javascript:rechne()"> <input id="ein" style="border-radius: 5px;border: 1px solid #d1d1d1;padding: 5px;max-width: 100px;text-align: center;" type="text" value="0 m" /><input style="background: none; border: none;" type="submit" value="ergibt" /> <span id="out01" style=" font-size: 32px; font-weight: bold;position: absolute;margin-top: -6px; padding-left: 15px;">0</span> </form> <p style="font-weight:bold; color:#4d4d4d; margin-top: 15px; font-size: 13px;"> Information </p> <p style="font-size:13px; color:#7E7E7E; margin-top: -10px"> Es werden automatisch 5% Verschnitt mit eingerechnet. </p> </div> </div>
Code: <div class="row row-60"> <div class="col-md-12"> <script type="text/javascript"> function rechne() { var eingabe=parseFloat("0"+document.getElementById("ein").value); var aus01=(Math.ceil(1.05*eingabe/2)).toFixed(0)+" Profile"; document.getElementById("out01").firstChild.data=aus01; } </script> <p style="font-weight:bold; color:#4d4d4d;"> Raumumfang (m) </p> <input id="ein" onchange="rechne()" onkeyup="rechne()" style="border-radius: 5px;border: 1px solid #d1d1d1;padding: 5px;max-width: 100px;text-align: center;" type="text" value="0 m" /> ergibt <span id="out01" style=" font-size: 32px; font-weight: bold;position: absolute;margin-top: -6px; padding-left: 15px;">0</span> <p style="font-weight:bold; color:#4d4d4d; margin-top: 15px; font-size: 13px;"> Information </p> <p style="font-size:13px; color:#7E7E7E; margin-top: -10px"> Es werden automatisch 5% Verschnitt mit eingerechnet. </p> </div> </div> Das sollte gehen.
<form action="javascript:rechne()"> da gehört das nicht hin. Dass das überhaupt funktioniert hat, wundert mich, aber ich bin auch kein JavaScript-Experte. Ich vermute, dass das eigentliche Problem war, dass sich der form-Tag auf der Artikelseite in einem anderen form-Block war, genau weiß ich es auch nicht.