Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/04/2014, 10:27
Avatar de nexus44
nexus44
 
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: Como obtengo variables que muestar un div

Buen día , estimados amigos muchas gracias por responder , aqui les muestro mi codigo , donde por medio de index.php traigo un listado mediante ajax de otra hoja , fechas.php y muestro ese listado en index.php con un div , entonces lo que yo intento hacer es que al momento que me lista todos los registros yo hacer un INSERT solo de los codigo que me muestra y es donde no se como obtener el valor , idprogramacion.

INDEX.PHP
Código PHP:
Ver original
  1. <?php
  2. $host="localhost";
  3. $user="root";
  4. $pass="";
  5. $base="colegio";
  6.  
  7. $conexion=mysql_connect($host,$user,$pass) or die ("ERROR");
  8.          mysql_select_db($base) or die ("error");        
  9.         ?>
  10. <script type="text/javascript">
  11. function newAjax(){
  12.       var xmlhttp=false;
  13.       try {
  14.          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  15.       } catch (e) {
  16.          try {
  17.             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  18.          } catch (E) {
  19.             xmlhttp = false;
  20.          }
  21.       }
  22.       if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  23.          xmlhttp = new XMLHttpRequest();
  24.       }
  25.    return xmlhttp;
  26. }
  27.  
  28. function BusquedaDato(){
  29.  
  30.    
  31.     var idnivel      = document.busqueda.idnivel.value;
  32.     var idgrado      = document.busqueda.idgrado.value;
  33.     var idseccion    = document.busqueda.idseccion.value;  
  34.     var idanno       = document.busqueda.idanno.value;
  35.    
  36.     ajax = newAjax();
  37.     ajax.open("POST", "fechas.php", true); 
  38.     ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
  39.    
  40.      document.getElementById('AjaxReporteAlumnos').innerHTML="<STRONG><center>CARGANDO DATOS...</center></STRONG>";
  41.     ajax.onreadystatechange = function () {
  42.         if (ajax.readyState == 4) {
  43.             document.getElementById('AjaxReporteAlumnos').innerHTML = ajax.responseText;
  44.             div.style.display = "";
  45.         }
  46.     }
  47.     //ajax.send('Tusuario='+Tusuario+'&ciclo='+ciclo+"&carrera="+carrera);
  48.     ajax.send('idnivel='+idnivel+'&idgrado='+idgrado+'&idseccion='+idseccion+'&idanno='+idanno);
  49.     }
  50. </script>
  51. <script type="text/javascript">
  52.  
  53.     ajax.open("POST", "fechas.php", true); 
  54. document.getElementById('AjaxReporteAlumnos').innerHTML = ajax.responseText;
  55. document.getElementById("idprogramacion").value = idprogramacion;
  56. </script>
  57.  
  58. <html>
  59. <input type="hidden" name="precio_total" value=" ">
  60. </html>
  61.  
  62. <html>
  63. <head>
  64. </head>
  65. <body>
  66. <center>
  67.  <form id="busqueda" name="busqueda" method="post" action="">  
  68.  <strong>BUSCA PROGRAMACION PARA ASIGNAR</strong>
  69.   <table width="90%" border="0" align="center"  class="down1">  
  70.   <tr>
  71.   <td>Nivel Academico:</td>
  72.   <td>
  73.     <select name="idnivel">
  74.     <?php
  75.     $sql=mysql_query("SELECT * FROM nivel_estudiantil");
  76.     while($dato=mysql_fetch_array($sql)){
  77.     ?> 
  78.     <option value="<?php echo $dato['idnivel'];?>"><?php echo $dato['descripcion'];?></option>
  79.     <?php } ?>
  80.     </select>  
  81.   </td>
  82.   <td>Grado:</td>  
  83.   <td>  
  84.     <select name="idgrado">
  85.     <?php
  86.     $sql=mysql_query("SELECT * FROM grados");
  87.     while($dato=mysql_fetch_array($sql)){
  88.     ?> 
  89.     <option value="<?php echo $dato['idgrado'];?>"><?php echo $dato['descripcion'];?></option>
  90.     <?php } ?>
  91.     </select>
  92.   </td>
  93.   </td>  
  94. <td>Seccion:</td>
  95.   <td>
  96.     <select name="idseccion">
  97.     <?php
  98.     $sql=mysql_query("SELECT * FROM seccion");
  99.     while($dato=mysql_fetch_array($sql)){
  100.     ?> 
  101.     <option value="<?php echo $dato['idseccion'];?>"><?php echo $dato['nombre'];?></option>
  102.     <?php } ?>
  103.     </select>
  104.   </td>  
  105.   <td>Año Academico:</td>
  106.   <td>
  107.     <select name="idanno">
  108.     <?php
  109.     $sql=mysql_query("SELECT * FROM annoacademico");
  110.     while($dato=mysql_fetch_array($sql)){
  111.     ?> 
  112.     <option value="<?php echo $dato['idanno'];?>"><?php echo $dato['descripcion'];?></option>
  113.     <?php } ?>
  114.     </select>
  115.   </td>
  116.    <td><input name="buscar" type="button" onClick="BusquedaDato()" class="btn btn-primary" style="cursor: pointer;"  value="BUSCAR" /></td>  
  117.   </tr>
  118.   </table>
  119.           </form>
  120.  
  121.     <form method="post" name="enviar" action="guardar.php">
  122.    
  123.     <div id="AjaxReporteAlumnos"> Esperando Acciones....       
  124.        </div>
  125.     </form>
  126.      
  127.   </center>
  128.  
  129. <?php
  130.  
  131.     for($i=0;$i<=10;$i++){
  132.         echo '<br/>';
  133.     }
  134.  ?>
  135.  
  136.  </body>
  137.  </html>

fechas.php

Código PHP:
Ver original
  1. <?php
  2. $host="localhost";
  3. $user="root";
  4. $pass="";
  5. $base="colegio";
  6.  
  7. $conexion=mysql_connect($host,$user,$pass) or die ("ERROR");
  8.             mysql_select_db($base) or die ("error");
  9. ?>
  10. <html>
  11. <head>
  12. <link href="css/bootstrap.css" rel="stylesheet">
  13.     <link href="css/bootstrap-responsive.css" rel="stylesheet">
  14.     <link href="css/docs.css" rel="stylesheet">
  15.     <link href="js/google-code-prettify/prettify.css" rel="stylesheet">
  16.    
  17.     <script>
  18.  
  19. function imprSelec(nombre)
  20.  
  21. {
  22.  
  23. var ficha = document.getElementById(nombre);
  24.  
  25. var ventimp = window.open(' ', 'popimpr');
  26.  
  27. ventimp.document.write( ficha.innerHTML );
  28.  
  29. ventimp.document.close();
  30.  
  31. ventimp.print( );
  32.  
  33. ventimp.close();
  34.  
  35. }
  36.  
  37. </script>
  38. </head>
  39. <body>
  40. <?php
  41.    
  42.     $idnivel    = $_POST['idnivel'];
  43.     $idgrado    = $_POST['idgrado'];
  44.     $idseccion  = $_POST['idseccion'];
  45.     $idanno     = $_POST['idanno'];
  46.    
  47.     if($idnivel==0){
  48.         echo '<img src="http://www.forosdelweb.com/f18/imagenes/error.gif"/> ERROR SELECCIONE OPCION';
  49.     }else{
  50. ?>
  51.  
  52.  
  53. <?php
  54.         $contador = 0;
  55.        
  56.  $sql="SELECT ne.idnivel , ne.descripcion , gr.idgrado ,gr.descripcion , se.idseccion , se.nombre ,an.idanno , an.descripcion ,do.doc_codigo , do.doc_nombres , do.doc_apellidos , cu.idcurso , cu.descripcion , pr.idprogramacion , pr.idnivel , pr.idgrado , pr.idseccion , pr.iddocente , pr.idcurso , pr.idanno FROM nivel_estudiantil ne , grados gr , seccion se, annoacademico an , docentes do ,cursos cu , programacion pr WHERE ne.idnivel=pr.idnivel AND gr.idgrado=pr.idgrado AND se.idseccion=pr.idseccion AND an.idanno=pr.idanno AND do.doc_codigo=pr.iddocente AND cu.idcurso=pr.idcurso AND pr.idnivel='".$idnivel."' AND pr.idgrado='".$idgrado."' AND pr.idseccion='".$idseccion."' AND pr.idanno='".$idanno."'";   
  57.         $rs  = mysql_query($sql,$conexion);
  58.         if(mysql_num_rows($rs)!=0){
  59. ?>
  60.  
  61. <table cellspacing="0" align="right">
  62.             <tr>
  63.             <td colspan=6 >
  64.             <a href="javascript:imprSelec('seleccion')" ><img src="img/print.png"></a>
  65.             </td>
  66.             </tr>
  67.             </table>
  68.             <div id="seleccion">
  69.             <table id="table" cellspacing="0" width="100%" border="1" class="table" align="center">            
  70.             <thead>
  71.             <tr class="asc" id="head">
  72.             <th align="center"><div align="center">Cod Programacion</div></th>
  73.             <th align="center"><div align="center">Curso</div></th>
  74.             <th align="center"><div align="center">Docente</div></th>
  75.             <th align="center"><div align="center">Seccion</div></th>          
  76.             </tr>
  77.             </thead>
  78.             <tbody id="tbody">
  79.  
  80.  
  81.    
  82.        
  83. <?php
  84.  
  85.  
  86.             while($row = mysql_fetch_assoc($rs)){
  87.  
  88.                            
  89.                 echo '<td><div align="center">'.$row['idprogramacion'].'</div></td>';
  90.                 echo '<input type="text" name"idprogramacion" value='.$row['idprogramacion'].'>';
  91.                 echo '<td><div align="center">'.$row['descripcion'].'</div></td>';         
  92.                 echo '<td><div align="center">'.$row['doc_nombres'].' '.$row['doc_apellidos'].'</div></td>';               
  93.                 echo '<td><div align="center">'.$row['nombre'].'</div></td>';              
  94.                 echo '</tr>';      
  95.             }
  96.            
  97. ?>
  98.  
  99. <?php          
  100.         }
  101.         else
  102.         echo 'NO EXISTE NINGUN TIPO DE PROGRAMACION PARA LO SELECCIONADO !';
  103. ?>
  104.             </tbody>       
  105.             </table>
  106. </div>
  107. <?php
  108.     }
  109. ?>
  110.  
  111. </body>
  112. </html>
__________________

"Nuestra capacidad se aleja de la Humanidad"