Tutaj kod całej strony + html
CODE
<html>
<head>
<title>Testy</title>
<script type="text/javascript">
function dodaj(co) {
if (co) {
document.getElementById('pole').value += co;
}else{
alert('Co mam dodać?!');
}
}
function usun(co) {
var dane = document.getElementById('pole').value;
if (dane) {
if (co) {
dane = substr(0, dane.lenght-co);
// Żadnen w komentarzu nie działa
// dane = substr(0, dane.lenght-1);
// dane = substring(0, dane.lenght-co);
// dane = substring(0, dane.lenght-1);
document.getElementById('pole').value = dane;
}else{
document.getElementById('pole').value = '';
}
}else{
alert('Co mam usunąć!?');
}
}
</script>
</head>
<body>
<center>
<table>
<tr>
<td><input type="submit" value="1" onclick="dodaj(1)"></td><td><input type="submit" value="2" onclick="dodaj(2)"></td>
<td><input type="submit" value="<-" onclick="usun(1)"></td>
</tr>
<tr>
<td><input type="submit" value="3" onclick="dodaj(3)"></td><td><input type="submit" value="4" onclick="dodaj(4)"></td>
<td><input type="submit" value="Reset" onclick="usun()"></td>
</tr>
</table>
<input type="text" id="pole" disabled="disabled">
</center>
</body>
</html>
Funkcja resetowania działa, ale jak chcę usunąć jeden znak to nic się nie dzieje...
Oczywiście dodawanie znaków działa bezproblemowo...