Return to Snippet

Revision: 101
at June 30, 2006 05:53 by mate


Updated Code
<script type="text/javascript"> 
function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
} 
</script>

HTML:

<form action="http://www.google.es">
Nombre: 
<input onkeypress="return handleEnter(this, event)" name="nombre">
<br>
Apellidos: 
<input onkeypress="return handleEnter(this, event)" name="apellidos">
<br>
Email:  
<input onkeypress="return handleEnter(this, event)" name="email">
<br>
Comentarios: 
<textarea rows=6 cols=40>

Revision: 100
at June 30, 2006 05:48 by mate


Initial Code
<script type="text/javascript"> 
function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
	return true;
} 
</script>

HTML:

<form action="http://www.google.es">
Nombre:&nbsp;
<input onkeypress="return handleEnter(this, event)" name="nombre">
<br>
Apellidos:&nbsp;
<input onkeypress="return handleEnter(this, event)" name="apellidos">
<br>
Email: &nbsp;
<input onkeypress="return handleEnter(this, event)" name="email">
<br>
Comentarios:&nbsp;
<textarea rows=6 cols=40></textarea>
<br>
<input type=submit value=Submit> 
</form>

Initial URL

                                

Initial Description
extraido de http://www.bloglines.com/myblogs

Initial Title
Utilizar la tecla intro como un tabulador de formulario

Initial Tags
html

Initial Language
JavaScript