Ver Mensaje Individual
  #7 (permalink)  
Antiguo 29/07/2008, 09:47
blackrocha
 
Fecha de Ingreso: noviembre-2004
Mensajes: 181
Antigüedad: 19 años, 6 meses
Puntos: 1
Respuesta: rescatar variables

te hago emvio del codigo php del formulario solo falata la parte de validacion q corregiste y los insert

if
{
}
else
{

$sdate=date("d")."/".date("m")."/".date("Y");
$año_actual=date("Y")-1;
$año_uno_menos= date("Y")-2;
$año_dos_menos= date("Y")-3;

echo"<form action='inscripcion_alumno.php?pasar=1' method='post' name='form1' >\n";
echo "<p>&nbsp;</p>";

echo"<center>\n";
//
echo"<hr align='center' width='880' >";
echo "<table width='70%' border='0' cellspacing='1' cellpadding='1' aling='center'>";
echo "<tr>";
echo "<td>Datos del alumno</td>";
echo "</tr>";
echo "</table>";
echo"<hr align='center' width='880' >";
//

echo "<table width='70%' border='0' cellspacing='1' cellpadding='1' aling='center'>";
echo "<tr>";
echo "<td>Fecha</td>";
echo "<td ><input type='text' name='fecha_inscripcion' value='$sdate'></td>";
echo "<td><pre>Rut Alumno </pre></td>";
echo "<td >";
echo"<input name='txtrut' type='text' value='' size='7' maxlength='8'>\n";
echo"<input name='digito' type='text' value='' size='1' maxlength='1'></td>";

echo "<td>&nbsp;</td>";
echo "<td >&nbsp;</td>";
echo "</tr>";
echo "<tr >";
echo "<td width='17%'><pre>Nombre </pre></td>";
echo "<td width='17%' ><input name='nombre_alumno' type='text' id='nombre_alumno' value='$nombre'></td>";
echo "<td width='17%'><pre>Apellido Paterno</pre></td>";
echo "<td width='16%' ><input name='apellido_paterno_alumno' type='text' id='apellido_paterno_alumno'></td>";
echo "<td width='15%'><pre>Apellido Materno</pre></td>";
echo "<td width='18%' ><input name='apellido_materno_alumno' type='text' id='apellido_materno_alumno'></td>";
echo "</tr>";
echo "<tr > ";
echo "<td><pre>Fecha Nacimiento</pre></td>";
//echo "<td></td>";
echo "<td><input type='text' name='alumno_fecha' id='f_date_c' size='10' onblur='calcular(this.value)' readonly='1' /><img src='img.gif' id='f_trigger_c' style='cursor: pointer; border: 1px solid red;' title='Date selector' onmouseover='this.style.background='red';' onmouseout='this.style.background='''/></td>";
echo "<td><pre>Edad </pre></td>";
echo"<td ><input name='edad' id='edad' type='numeric' value='' onKeyPress='return acceptNum(event)' size='20' readonly></td>";


echo "<td><pre>Domicilio </pre></td>";
echo "<td ><input name='alumno_domicilio' type='text' id='alumno_domicilio'></td>";
echo "</tr>";
echo "<tr > ";
/////////////////////ciudad
$sql = "SELECT * FROM ciudad__ciud";
$res = mysql_query($sql) or die("La consulta fall&oacute;: " . mysql_error());
$num=mysql_numrows($res);
echo "<td><pre>ciudad </pre></td>";
echo "<td ><select name='ciudad' id='ciudad'>";
echo "<option value=''>(seleccione Ciudad)</option>";
for ($i=0; $i<$num; $i++)
{
$id_familia=mysql_result($res,$i,"CIUD_CODIGO");
$nombre=mysql_result($res,$i,"CIUD_NOMBRE");
echo "<option value=$id_familia>$nombre</option>";
}
echo "</select></td>";
////////////////////////////////
echo "<td height='28'><pre>Telefono</pre></td>";
echo "<td><input type='text' name='telefono'></td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
echo "</table>";

////
echo"<hr align='center' width='880' >";
echo "<table width='70%' border='0' cellspacing='1' cellpadding='1' aling='center'>";
echo "<tr>";
echo "<td>Datos Academicos</td>";
echo "</tr>";
echo "</table>";
echo"<hr align='center' width='880' >";
///
echo "<table width='70%' border='0' cellspacing='1' cellpadding='1'>";
echo "<tr >";
echo "<td><pre>Promedios años anteriores</pre></td>";
echo "<td ><input name='ano1' value='$año_actual' type='text' id='ano_1' size='5' readonly>";
echo "-";
echo "<input name='pro1' type='text' id='pro1' size='5'></td>";
echo "<td ><input name='ano2' value='$año_uno_menos' type='text' id='ano2' size='5' readonly>";
echo "-";
echo "<input name='pro2' type='text' id='pro2' size='5'></td>";
echo "<td ><input name='ano3' value='$año_dos_menos' type='text' id='ano3' size='5' readonly>";
echo "-";
echo "<input name='pro3' type='text' id='pro3' value='' size='5'></td>";
echo "</tr>";

echo "<td ></td>";
echo "<td>&nbsp;</td>";
echo "<td>&nbsp;</td>";
echo "<td>&nbsp;</td>";
echo "</tr>";

echo "</table>";
echo"<input type='button' name='btnagregar' value='Generar inscripcion' onclick='validar()' >\n";
//
echo "<p>&nbsp;</p>";
//fin form
echo"</form>\n";
echo "<font color='#000000'>&nbsp;</font></td>";
echo "</tr>";
echo"</center>\n";
echo "</table>";
?>
<script language="javascript" src="definir-menus.txt" type="text/javascript"></script>
<?php
echo "</body>";
echo "</html>";
}
?>
validacion javascript
function validar()
{
rut = document.form1.txtrut.value;
digito = document.form1.digito.value;

rut_sin_digito=new Array(0,0,0,0,0,0,0,0);
constante= new Array(3,2,7,6,5,4,3,2);

sep_rut=document.form1.txtrut.value;
digito=document.form1.digito.value;

rut_sin_digito[0]=sep_rut.charAt(0);
rut_sin_digito[1]=sep_rut.charAt(1);
rut_sin_digito[2]=sep_rut.charAt(2);
rut_sin_digito[3]=sep_rut.charAt(3);
rut_sin_digito[4]=sep_rut.charAt(4);
rut_sin_digito[5]=sep_rut.charAt(5);
rut_sin_digito[6]=sep_rut.charAt(6);
rut_sin_digito[7]=sep_rut.charAt(7);
suma=0;

for(ind=0;ind<8;ind++)
{
suma = suma + (rut_sin_digito[ind]*constante[ind]);
}
resto = suma % 11;
digito_correcto = 11 - resto;

if (digito_correcto == 10)
{ digito_correcto = "k";
}
else if (digito_correcto == 11)
{ digito_correcto = 0;
}

if (digito_correcto == digito)
{
form1.submit();
}
else
{alert('Rut Incorrecto ');
}
}
lo otro es casi lo mismo q postie arriva... ojala te sirva