Salve a tutti. Stavo cercando di fare una calcolatrice in javascript e in html e questo è quello che sono riuscito a fare:
<html>
<head>
<script lan="javascript">
function aggiungi(n) {
document.form1.a.value=document.form1.a.value+n}
function cancella() {
document.form1.a.value=''}
function opposto(x) {
num1=eval(x)
num1=-num1
document.form1.a.value=num1}
</script>
</head>
<body>
<form name="form1">
<table align="center" border=1>
<tr><td colspan=5>
<textarea cols=24 rows=2 value="" name="a"></textarea></td></tr>
<tr>
<td><input type="button" value=" 7 " onClick="aggiungi('7')"></td>
<td><input type="button" value=" 8 " onClick="aggiungi('8')"></td>
<td><input type="button" value=" 9 " onClick="aggiungi('9')"></td>
<td align="center" colspan=2><input type="button" value=" CANC " onClick="cancella()"></td>
</tr>
<tr>
<td><input type="button" value=" 4 " onClick="aggiungi('4')"></td>
<td><input type="button" value=" 5 " onClick="aggiungi('5')"></td>
<td><input type="button" value=" 6 " onClick="aggiungi('6')"></td>
<td><input type="button" value=" * " onClick="aggiungi('*')"></td>
<td><input type="button" value=" / " onClick="aggiungi('/')"></td>
</tr>
<tr>
<td><input type="button" value=" 1 " onClick="aggiungi('1')"></td>
<td><input type="button" value=" 2 " onClick="aggiungi('2')"></td>
<td><input type="button" value=" 3 " onClick="aggiungi('3')"></td>
<td><input type="button" value=" + " onClick="aggiungi('+')"></td>
<td><input type="button" value=" - " onClick="aggiungi('-')"></td>
</tr>
<tr>
<td><input type="button" value=" 0 " onClick="aggiungi('0')"></td>
<td><input type="button" value=" . " onClick="aggiungi('.')"></td>
<td><input type="button" value=" +/- " onClick="opposto(form1.a.value)"></td>
<td align="center" colspan=2><input type="button" value=" = " onClick="totale(form1.a.value)"></td>
</tr>
</table>
</form>
</body>
</html>
Ora vi chiedo un aiuto, non so come procedere per creare la funzione che fa tutti i calcoli, e una funzione che metta le parentesi tonde anche, e che tutto ciò che io premo, sia memorizzato in un <textarea name="b"....></textarea>.... Mi capite?...Per Favore Aiutatemi.