Ver Mensaje Individual
  #10 (permalink)  
Antiguo 22/06/2008, 08:40
anion0x
 
Fecha de Ingreso: junio-2008
Mensajes: 110
Antigüedad: 16 años, 8 meses
Puntos: 0
Respuesta: agregar input a un form

Estuve haciendo algo como esto:

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test jQuery</title>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.highlightFade.js"></script>

<script type="text/javascript">
var contador = 0;

function addFormField() {
	$("#divTxt").append("<input type=\"text\" name=\"idioma + contador \">");
	contador++;
}
</script>

<body>

<p><a href="#" onClick="addFormField(); return false;">Add</a></p>

<form action="#" method="get" id="form1">

<div id="divTxt"></div>
<?php  
	echo $_GET['idioma'];

?>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>
</form>

</body>
</html>
La idea es tener un contador, y que cada vez que se lanza el evento onclick me agregue un input, y que el nombre sea
idioma0
idioma1
idioma2
para luego poder manejarlos desde php, pero no se como terminarlo.