Gracias de antemano.
El problema es que no muestra lo almacenado en el arreglo.
Código:
<h1>Registrar Usuario</h1><script> var arregloAlumnos = new Array(); var objetoAlumno = {"nombre" : null , "apellido" : null}; function agregarUsuario() { var valorNombre = document.formulario.nombre.value; var valorApellido = document.formulario.apellidos.value; arregloAlumnos.push({"nombre" : valorNombre , "apellido" : valorApellido}); alert(arregloAlumnos.length); } function mostrarUsuarios() { for ( i=0 ; i<arregloAlumnos.length ; i++) { document.getElementById('listadoUsuarios').innerHTML += arregloAlumnos[i].valorNombre+'<br>'; } } </script>
<form name="formulario" >
<table>
<tr>
<td>Nombre : </td>
<td><input type="text" name="nombre" /></td>
</tr>
<tr>
<td>Apellidos : </td>
<td><input type="text" name="apellidos" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Registrarse" onclick="agregarUsuario();"/></td>
</tr>
</table>
</form>
<input type="button" value="Mostrar usuarios" onClick="mostrarUsuarios();"/>
<div id="listadoUsuarios">
</div>
Código HTML: