
Ayuda parar borrar el ultimo elemento de una cadena
Publicado por ASTRID (7 intervenciones) el 23/09/2015 16:37:47
Hola les voy a pedir su ayuda sobre un teclado virtual para escribir simbolos matematicos que estoy tratando de hacer, soy nueva en la prgramación y me gustaria saber como hago para hacer un boton que borre digito a digito como en las calculadoras y no todo de golpe... Esto es lo que hice; y la parte de la function de borrarUno me dijeron que serviria pero la puse ahi y no me sirvio :( Les agradezco su ayuda.. chao
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script>
// JavaScript Document
var cifra="";
var valores=[];
function display_ecuacion(num){
valores.push(num);
cifra= document.getElementById("display").value;
document.getElementById("display").value= cifra+num;
}
function resetearDisplay(){
document.getElementById("display").value ="";
cifra = "";
}
function borrarUno(num) {
valores.push(num);
var contenido= documet.getElementById("display").value;
document.getElementById("display").value= contenido.substring(0, contenido.length-1);
}
</script>
<style>
.tamBot{
width:30px;
height:30px;
padding:2px;
font-size:150;
font-weight:bolder;
font-style:italic;
color:#181531;
background-color:#E8F7EE;
float:left;}
.tablita{
float:none;
margin:20px;
width:200px;
font-size:1em;
font-weight:400;}
</style>
</head>
<body>
<form action="" name="ejercicio" method="post" enctype="multipart/form-data" >
<div class="dom">Dom( f )={</div><input name="display" type="text" id="display" class="display" required/> <div class="dom">}</div>
<input name="elreset" type="button" class="dom2" id="borro" value="Borrar" onClick="resetearDisplay()">
<br><br>
<table class="tablita" border="1" >
<tr>
<td width="5%"><input name="button1" type="button" class="tamBot" id="button1" value="x²" onClick="display_ecuacion('\xB2')"></td>
<td width="5%"><input name="button2" type="button" class="tamBot" id="button2" value="x³"onClick="display_ecuacion('\xB3')"></td>
<td width="5%"><input name="button3" type="button" class="tamBot" id="button3" value="=" onClick="display_ecuacion('=')"></td>
<td width="5%"><input name="button4" type="button" class="tamBot" id="button4" value="≠" onClick="display_ecuacion('\u2260')"></td>
<td width="5%"><input name="button5" type="button" class="tamBot" id="button5" value="≤" onClick="display_ecuacion('\u2264')"></td>
<td width="5%"><input name="button6" type="button" class="tamBot" id="button6" value="≥" onClick="display_ecuacion('\u2265')"></td>
</tr>
<tr>
<td width="5%"><input name="button7" type="button" class="tamBot" id="button7" value="∞" onClick="display_ecuacion('\u221E')"></td>
<td width="5%"><input name="button8" type="button" class="tamBot" id="button8" value="∈" onClick="display_ecuacion('\u2208')"></td>
<td width="5%"><input name="button9" type="button" class="tamBot" id="button9" value="√" onClick="display_ecuacion('\u221A')"></td>
<td width="5%"><input name="button10" type="button" class="tamBot" id="button10" value="∪" onClick="display_ecuacion('\u222A')"></td>
<td width="5%"><input name="button11" type="button" class="tamBot" id="button11" value="│x│" onClick="display_ecuacion(' \|x\|')" ></td>
<td width="5%"><input name="button12" type="button" class="tamBot" id="button12" value="ℜ" onClick="display_ecuacion('\u211C')"></td>
</tr>
</table>
<input type="button" value="borrar último" onClick="borrarUno()" />
<input type="submit" value="Corregir" class="dom2" />
</form>
</div>
</body>
</html>
Valora esta pregunta


0