Nieuw lid |
|
Ik ben nog maar juist bezig met JavaScript maar hoe laat je dit deftig werken ?? dan kan ik al een stuk verder
<html>
<head>
<title>Functies in JavaScript</title>
<script type="text/javascript">
function Calc(a, b, operator)
{
var C;
switch( operator )
{
case 1: C = a+b;
break;
case 2: C = (a-b);
break;
case 3: C = (a*b);
break;
case 4: C = (a/b);
break;
}
document.Rekenblad.uitkomst.write(C);
}
</script>
</head>
<body>
<form name="Rekenblad">
<input type="text" name="a" />
<select name="operator">
<option value="1">+</option>
<option value="2">-</option>
<option value="3">*</option>
<option value="4">/</option>
</select>
<input type="text" name="b" />
<input type="button" value=" = " onclick="Calc()" />
<input type="text" name="uitkomst" value="" />
</form>
</body>
</html>
<html> <head> <title>Functies in JavaScript</title> <script type="text/javascript"> function Calc(a, b, operator) { var C; switch( operator ) { case 1: C = a+b; break; case 2: C = (a-b); break; case 3: C = (a*b); break; case 4: C = (a/b); break; } document.Rekenblad.uitkomst.write(C); } </script> </head> <body> <form name="Rekenblad"> <input type="text" name="a" /> <select name="operator"> <option value="1">+</option> <option value="2">-</option> <option value="3">*</option> <option value="4">/</option> </select> <input type="text" name="b" /> <input type="button" value=" = " onclick="Calc()" /> <input type="text" name="uitkomst" value="" /> </form> </body> </html>
|