Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/07/2010, 19:14
sathory
 
Fecha de Ingreso: julio-2010
Mensajes: 16
Antigüedad: 14 años, 7 meses
Puntos: 0
Añadir textbox segun numero

hola, es mi primera vez escribiendo y por cierto me encanta este foro de lo mejor que hay

bueno espero que me puedan ayudar
el asunto es este tengo una casilla en la que me dan un numero entre 1 y 100 y un boton

si me dicen "10" la idea es que se creen 10 textbox

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
		<script type=text/javascript>
			function revisa(valor, fil)

			{
				var valido=0
				for (var i = 0; i < valor.length; i++) {
					var caracter = valor.substring(i, i+1)
					if (caracter != "0" && caracter != "1" && caracter != "2" && caracter != "3" && caracter != "4" && caracter != "5" && caracter != "6" && caracter != "7" && caracter != "8" && caracter != "9") 
					{
							alert("Solo estan permitidos los numeros enteros")
							valido++ 		
					}
					
				 } 
				 if( valor>100)
				 {valido++}
				 if(valido>0)
				 {document.inicio.cantidad.value=""}
				 else
				 {
				 	
					for(var j=1; j<=valor; j++)
					{
						  obj=fil.form;
						  num++;
						  elem=document.createElement('input');
						  elem.name='algo' + num;
						  elem.type="file";
						  obj.appendChild(elem);
					}
				 }

			}
			
	</script>
    </head>
    <body>
    	   	<form name="inicio" action="" method="post">
    	   	<label for "cantidad">Escriba la cantidad de datos a agregar: </label>
        	<input type="text" name="cantidad" >
			<input type="button" name="acepta" value="Aceptar" onclick="revisa(cantidad.value, this)">
			<ul id="lista"></ul>
			<h5>(Enteros entre 1 y 100)</h5>
			</form>
			
			
    </body>
</html>