Necesito hacer lo siguiente (soy un principiante en programación así que discúlpeme por mi ignorancia): tengo que pedirle al usuario tres datos diferentes en tres cuadros de texto diferentes en una formar. Luego el usuario tiene un botón llamado "enter" y cuando hace clic en él los textos que ingresó en los tres campos deben almacenarse en tres arreglos diferentes, en esta etapa también quiero ver que la información del usuario para verificar los datos se está almacenando en el conjunto. He intentado infructuosamente hacer que la aplicación almacene o muestre los datos en solo una de las matrices. Tengo 2 archivos: film.html y functions.js. Aquí está el código. ¡Cualquier ayuda será apreciada!almacenando la entrada del usuario en la matriz
<html>
<head>
<title>Film info</title>
<script src="jQuery.js" type="text/javascript"></script>
<script src="functions.js" type="text/javascript"></script>
</head>
<body>
<div id="form">
<h1><b>Please enter data</b></h1>
<hr size="3"/>
<br>
<label for="title">Title</label> <input id="title" type="text" >
<br>
<label for="name">Actor</label><input id="name" type="text">
<br>
<label for="tickets">tickets</label><input id="tickets" type="text">
<br>
<br>
<input type="button" value="Save" onclick="insert(this.form.title.value)">
<input type="button" value="Show data" onclick="show()"> <br>
<h2><b>Data:</b></h2>
<hr>
</div>
<div id= "display">
</div>
</body>
</html>
var title=new Array();
var name=new Array();
var tickets=new Array();
function insert(val){
title[title.length]=val;
}
function show() {
var string="<b>All Elements of the Array :</b><br>";
for(i = 0; i < title.length; i++) {
string =string+title[i]+"<br>";
}
if(title.length > 0)
document.getElementById('myDiv').innerHTML = string;
}
No se olvide de .valorar estos para obtener el valor de lo que se ingresó en el campo de entrada –
¡Muchas gracias! ¡Este sitio es genial! Estudiaré tus correcciones y seguiré trabajando. Gracias de nuevo –