return

Beispiel 1: return

head>
script type="text/javascript">
function PrimzahlCheck (Zahl) {
Zahl = parseInt(Zahl, 10);
if (isNaN(Zahl)) {
alert("Sie müssen eine Zahl eingeben!");
return;
}
var Grenzzahl = Zahl / 2;
var Check = 1;
for (var i = 2; i <= Grenzzahl; i++)
if (Zahl % i == 0) {
alert(Zahl + " ist keine Primzahl, weil teilbar durch " + i);
Check = 0;
}
if (Check == 1)
alert(Zahl + " ist eine Primzahl!");
}
/script>
/head>
body>


Geben Sie eine Zahl ein. Es wird geprüft, ob es sich um eine Primzahl handelt.


onclick="PrimzahlCheck(document.PrimzahlFormular.Eingabezahl.value)">

/body>

Beispiel 2: return Ergebnis;

head>
Test
script type="text/javascript">
function BruttoBetrag (Netto, Prozente) {
var Ergebnis = Netto * (1 + (Prozente / 100));
return Ergebnis;
}

function SchreibeBrutto (Betrag, Prozentsatz) {
var Wert = BruttoBetrag(Betrag, Prozentsatz);
document.BruttoForm.Ergebnisfeld.value = Wert;
}

/head>
body>



Nettobetrag:
Prozentsatz:

Kommabetrag mit Punkt eingeben!

onclick="SchreibeBrutto(document.BruttoForm.NettoEingabe.value,document.BruttoForm.ProzentEingabe.value)">

Ergebnis:


/body>