I noticed something interesting for me that I'm new and it's that I was doing a function in javascript to call it and use it with the event onclick
, then when putting the event in the HTML code and put onclick="function("mibg")"
a parameter with any name. the code gives me an error that the parameter mibg
does not exist, but if instead I give it another word like this
, if it works.
Then I would like to know if it only detects a word like parameters the events or why this happens ?. thank you very much
<html>
<head>
<meta charset="utf-8">
<title>Calculadora Personal </title>
<link rel="stylesheet" href="css/calculadora_personal.css">
</head>
<body id="todo">
<div>
<center>
<table border="0" width="250px" height="60" id="operaciones">
<tr>
<td height="50px" colspan="4"><label for="operador"></label>
<input type="text" name="operador" id="pantalla" value=""></td>
</tr>
<tr>
<td class="cuadros"><input type="button" value="1" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="2" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="3" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="+" name="boton" class="boton" onclick="operaciones(this)"></td>
</tr>
<tr>
<td class="cuadros"><input type="button" value="4" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="5" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="6" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="-" name="boton" class="boton" onclick="operaciones(this)"></td>
</tr>
<tr>
<td class="cuadros"><input type="button" value="7" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="8" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="9" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="*" name="boton" class="boton" onclick="operaciones(this)"></td>
</tr>
<tr>
<td class="cuadros"><input type="button" value="clr" name="boton" class="boton" onclick=""></td>
<td class="cuadros"><input type="button" value="0" name="boton" class="boton" onclick="ingresa_dato(this)"></td>
<td class="cuadros"><input type="button" value="=" name="boton" class="boton" onclick="resultado('res')"></td>
<td class="cuadros"><input type="button" value="/" name="boton" class="boton" onclick="operaciones(this)"></td>
</tr>
</table>
</center>
</div>
<script src="js/Calculadora_personal.js"></script>
</body>
</html>
var valor = document.getElementById("pantalla");
function ingresa_dato(obj){
valor.value += obj.value;
console.log(obj.value);
}
function operaciones(ope) {
var operacion =
valor.value += ope.value;
console.log(valor.value);
}
function resultado(resultado){
}