Ver Mensaje Individual
  #11 (permalink)  
Antiguo 25/09/2009, 14:42
Avatar de kuriel
kuriel
 
Fecha de Ingreso: febrero-2009
Mensajes: 240
Antigüedad: 15 años, 2 meses
Puntos: 4
Cita:
Iniciado por GatorV Ver Mensaje
Envialos como un array usando una nomenclatura similar:
Código HTML:
Ver original
  1. <input type="text" name="nombres[]" />

Luego en PHP lo ciclas:
Código PHP:
Ver original
  1. foreach ($_POST['nombres'] as $nombre) {
  2.       echo $nombre;
  3. }

Saludos.
Cita:
Iniciado por GatorV Ver Mensaje
El código que puse no es para que lo uses tal cual, es para que aprendas y entiendas como recibir los campos, si usas el var_dump que te puso pato12 vas a poder ver la estructura de $_POST y ver la forma de ciclarlo.

Saludos.

Jajaja... Me ofendes, claro que ya se que no se pone tal cual, tengo que adaptarlo a mis variables y a mi JavaScript...

Me falta aprender de PHP pero no soy tonto...

Pero de plano no andan estos codigos

TENGO ESTO:


Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<?php
if ($_POST['submit']) {
foreach (
$_POST['menu'] as $nombre) {
      echo 
$nombre;
}
}
else {
?>
<script type="text/javascript">
// AGREGAMOS O QUITAMOS CAMPOS
counter = 2;
function agregarCampo()
    {
        var x = document.getElementById("mascampos");
        var campo = document.createElement("input");
        campo.setAttribute('type', "text");
        campo.setAttribute('name', "menu[]");
        campo.setAttribute('id', "menu"+counter);
        
        var campo2 = document.createElement("input");
        campo.setAttribute('type', "text");
        campo.setAttribute('name', "enlace[]");
        campo.setAttribute('id', "enlace"+counter);
        
        var br = document.createElement("br");
        x.appendChild(document.createTextNode("Menu "+counter+": "));
        x.appendChild(campo);
        
        x.appendChild(document.createTextNode(" Enlace de menu "+counter+": "));
        x.appendChild(campo2);
        
        x.appendChild(br);
        counter++;
    }
function borrarElemento()
    {
        var x = document.getElementById("mascampos");
        x.removeChild(x.lastChild);
        x.removeChild(x.lastChild);
        x.removeChild(x.lastChild);
        x.removeChild(x.lastChild);
        x.removeChild(x.lastChild);
        counter--;
    }
    </script>
<form name="kuriel" method="post" action="1.php">
<a style="color:orange;" href="#" onClick="agregarCampo()">A&ntilde;adir un MENU</a> | <a style="color:orange;" href="#" onClick="borrarElemento()">Quitar un MENU</a></h6>
<div id="mascampos">
Menu 1: <input type="text" name="menu[]" /> Enlace de menu 1: <input type="text" name="enlace1" id="enlace1" /><br />
</div>

<input type="submit" value="submit" name="submit" />
</form>

<? 
}
?>
</body>
</html>
__________________
Si todas las URL's que tienes o visitas te parecen largas, visita www.korto.tk - También protege de rastros y con contraseñas tus páginas o URL's.

Última edición por GatorV; 26/09/2009 a las 15:11