Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/02/2008, 14:02
yosvany
 
Fecha de Ingreso: agosto-2006
Ubicación: Cuba
Mensajes: 23
Antigüedad: 18 años, 7 meses
Puntos: 0
Re: Añadir propiedad a campo de texto ?

Gracias Caricatos

Me sirvio la idea que me diste, hice un pequeño ejemplo para que todos los campos input de tipo texto tengan esa funcionalidad.Este es el codigo del ejemplo:

Codigo:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
window.onload = function(){
//Arreglo de todos los input de la pagina
var arrInputs = document.getElementsByTagName("input");
var cantElementos = arrInputs.length;

for (var i = 0;i < cantElementos;i++){
if(arrInputs.item(i).type == 'text'){

arrInputs.item(i).clear = function(){
this.value = '';
this.focus();
}
}
}
}
//-->
</script>
</head>

<body>
<input type="text" name="nombre" id="nombre" />
<input type="button" name="Limpiar" value="Limpiar" onClick="document.getElementById('nombre').clear() ;"/>
</body>
</html>