<?
session_start();
?>
<html>
<head>
<script type="text/javascript">
num=0;
function crearHermano(obj) {
num++;
//Creamos los datos del hermano
fi = document.getElementById('f1');
contenedor = document.createElement('div');
contenedor.id = 'div'+num;
fi.appendChild(contenedor);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createTextNode('DNI: '); //Creamos el DNI
ele = document.createElement('input');
ele.type = 'text';
ele.name = 'cDNIH'+num;
contenedor.appendChild(txt);
contenedor.appendChild(ele);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
//Creamos el nombre
txt = document.createTextNode('Nombre: ');
ele = document.createElement('input');
ele.type = 'text';
ele.name = 'cNombreH'+num;
ele.size = '40';
contenedor.appendChild(txt);
contenedor.appendChild(ele);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
txt = document.createElement('
<br>'); // Meto un salto de línea
contenedor.appendChild(txt);
ele = document.createElement('input');
ele.type = 'button';
ele.value = 'Borrar';
ele.name = 'div'+num;
ele.onclick = function () {borrar(this.name)}
contenedor.appendChild(ele);
}
function borrar(obj) {
fi = document.getElementById('f1');
fi.removeChild(document.getElementById(obj));
}
</script>
<title>Crear datos familiares
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
include("conexion.php");
echo '<form name="f" id="f1" method = "POST" action ="guardarDatosFamiliares.php" OnSubmit="return validar(this)">
//Esto iba antes dentro de un fieldset
<h2>Nuevo hermano</h2>
<input type="button" value="Añadir Hermano" onclick="crearHermano(this)">
</div>
<br><br>
';
//Hasta aqui llegaba el fieldset
echo'<input name="nHermanosCreados" type="hidden" value="">';
echo '<div style="margin-left: 3%; width=200px;">
Padre: <input name="cNombreP" type="text" size="40">
   Edad: <input name="cEdadP" size="3" type="text">
   Estado civil:
<select name="cECivilP">
<option value="Soltero">Soltero</option>
<option value="Casado">Casado</option>
<option value="Separado">Separado</option>
<option value="Viudo">Viudo</option>
</select>
<br><br>
Estudios: <input name="cEstudiosPadre" type="text">
   Profesión: <input name="cProfesionP" size="40" type="text">
   Situación laboral:
<select name="cSituacionLaboralP">
<option value="Activo">Activo</option>
<option value="Desempleado">Desempleado</option>
<option value="Sus labores">Sus labores</option>
<option value="Invalidez">Invalidez</option>
</select>
<br><br>';
echo '
<input name="botonGuardar" type="submit" value="Guardar">
</form>';
?>
</body>
</html>