Ver Mensaje Individual
  #10 (permalink)  
Antiguo 29/04/2013, 17:27
steffyn_90
 
Fecha de Ingreso: noviembre-2012
Ubicación: Tegucigalpa
Mensajes: 94
Antigüedad: 11 años, 5 meses
Puntos: 0
Respuesta: Problemas con checkbox

Pues aqui le dejo todo la pagina jejejejeje..


Código PHP:
Ver original
  1. <?php
  2. ?>
  3.  
  4.  
  5.  
  6. <!doctype html>
  7. <html>
  8. <head>
  9. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  10. <script type="text/javascript" src="acc_calendar/acc_calendar.js"></script>
  11. <title>Untitled Document</title>
  12. </head>
  13.  
  14.  
  15.  
  16. <body>
  17. <script type="text/javascript" >
  18. function addRow(seccion) {
  19.             var table = document.getElementById(seccion);                    
  20.             var rowCount = table.rows.length;
  21.             var row = table.insertRow(rowCount);
  22.             var colCount = table.rows[0].cells.length;
  23.                 cant = rowCount ;
  24.             for(var i=0; i<colCount; i++) {
  25.                 var newcell = row.insertCell(i);
  26.                 newcell.innerHTML = table.rows[0].cells[i].innerHTML;
  27.                 //alert(newcell.childNodes);
  28.                
  29.                 cant = cant + 1;
  30.                 switch(newcell.childNodes[0].type) {
  31.                     case "text":
  32.                             newcell.childNodes[0].value = "";
  33.                             break;
  34.                     case "checkbox":
  35.                             newcell.childNodes[0].checked = false;
  36.                             break;
  37.                     case "select-one":
  38.                             newcell.childNodes[0].selectedIndex = 0;
  39.                             break;
  40.                 }
  41.             }
  42.         }
  43. </script>
  44.  
  45.  
  46. <?php
  47.  
  48. include "config.php";
  49.  if(!$link){
  50.     die ("No se ha podido completar la conexion.". mysql_error());
  51.     }
  52.  if(!$_POST ){
  53. ?>
  54.  
  55.  
  56.  
  57.  <?php
  58. $fecha =strftime("%Y-%m-%d", time());
  59. $codigo_plan=$_REQUEST['id'];
  60. $codigo_plan = $_SESSION['codigo_plan'] ;  
  61. $cantidad = $_SESSION['cantidad'] ;
  62.  
  63.  
  64.  
  65. $query = ("SELECT a.nombre_carrera FROM carrera a, plan_estudio b
  66. WHERE a.codigo_carrera = b.codigo_carrera and b.codigo_plan = $codigo_plan ") or die(mysql_error());
  67. $resultado= mysql_query ($query, $link);
  68.    if (mysql_num_rows ($resultado)>=1){
  69.    while($row = mysql_fetch_assoc ($resultado)) {      
  70.    $nombre_carrera=$row['nombre_carrera'];}
  71.    }
  72. ?>  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. <form action="seccion2.php" method="post" name="aula">
  79. <br>
  80. <div align="center"><h2><strong><font size="+3" color="#0009A8"> Carga Academica</font></strong></h2></div>
  81.  
  82. <table align="center">
  83.   <tr>
  84.     <td align="center"> <strong> Curso </strong> </td>
  85.     <td align="center" width="7"> <strong> L </strong> </td>
  86.     <td align="center" width="7"> <strong> M </strong> </td>
  87.     <td align="center" width="7"> <strong> Mi </strong> </td>
  88.     <td align="center" width="7"> <strong> J </strong> </td>
  89.     <td align="center" width="7"> <strong> V </strong> </td>
  90.     <td align="center" width="7"> <strong> S </strong> </td>
  91.     <td align="center" width="7"> <strong> D </strong> </td>
  92.     <td align="center" > <strong> Hora Inicio </strong> </td>
  93.     <td align="center"> <strong> Hora Final </strong> </td>
  94.   </tr>
  95.  </table>
  96.  
  97.  
  98.  
  99. <?php
  100.   for ($i = 1; $i <= $cantidad; $i++) {
  101. ?>
  102. <table align="center" id="seccion">
  103.  <tr>
  104. <td> <?php
  105. $con="SELECT nombre_curso FROM curso WHERE codigo_plan = $codigo_plan";
  106. $res=@mysql_query($con,$link);
  107. if(!$res){
  108. echo "fallo la conexion";
  109. }
  110. else{
  111. echo "<select name= 'curso1[]' style='width:200px'>";
  112. while ($fila=mysql_fetch_array($res)){
  113. echo "<option>", $fila['nombre_curso'], "</option>";
  114. }}
  115. echo "</select>";
  116. echo "
  117.    </td>
  118.    <td align='center'><input name= 'l[]' type='checkbox' value='x'></td>
  119.    <td align='center'><input name= 'm[]' type='checkbox' value='x'></td>
  120.   <td align='center'><input name= 'mi[]' type='checkbox' value='x'></td>
  121.    <td align='center'><input name= 'j[]' type='checkbox' value='x'></td>
  122.    <td align='center'><input name= 'v[]' type='checkbox' value='x'></td>
  123.    <td align='center'><input name= 's[]' type='checkbox' value='x'></td>
  124.    <td align='center'><input name= 'd[]' type='checkbox' value='x'></td>
  125. <td>
  126. <select name= 'hi[]'>
  127. <option > -----</option>
  128. <option > 07</option>
  129. <option > 08</option>
  130. <option > 09</option>
  131. <option > 10</option>
  132. <option > 11</option>
  133. <option > 12</option>
  134. <option > 13</option>
  135. <option > 14</option>
  136. <option > 15</option>
  137. <option > 16</option>
  138. <option > 17</option>
  139. <option > 18</option>
  140. <option > 19</option>
  141. <option > 20</option>
  142. </select>
  143.  
  144. <select name= 'mi1[]'>
  145. <option > -----</option>
  146. <option > :00 </option>
  147. <option > :30 </option>
  148. </select></td>
  149.  
  150.  
  151.  
  152. <td>
  153. <select name= 'hf[]'>
  154. <option > -----</option>
  155. <option > 07</option>
  156. <option > 08</option>
  157. <option > 09</option>
  158. <option > 10</option>
  159. <option > 11</option>
  160. <option > 12</option>
  161. <option > 13</option>
  162. <option > 14</option>
  163. <option > 15</option>
  164. <option > 16</option>
  165. <option > 17</option>
  166. <option > 18</option>
  167. <option > 19</option>
  168. <option > 20</option>
  169.  
  170. </select>
  171. <select name= 'mf[]'>
  172. <option > -----</option>
  173. <option > :00 </option>
  174. <option > :30 </option>
  175. </select>
  176.  
  177. </td>
  178. </tr>
  179.  
  180. ";
  181.  
  182.   }
  183.  
  184. ?>
  185.  
  186. </table>
  187.  
  188.  
  189.  
  190. <br>
  191.  
  192. <div align="center"><input type="submit" name="Aceptar" value="Guardar"  /></div>
  193. <INPUT type="button" value="Add Row" onclick="addRow('seccion')" />
  194.  
  195. <div align="center"><input type="hidden" name="cantidad" value="<?php echo $cantidad; ?>"  /></div>
  196.  
  197. <div align="center"><input type="hidden" name="codigo_plan" value="<?php echo $codigo_plan; ?>"  /></div>
  198.  
  199. <div align="center"><input type="hidden" name="trimestre" value="<?php echo $tri; ?>"  /></div>
  200.  
  201. </form>
  202.  
  203.  
  204.  
  205. <?php
  206.  
  207.  }else{
  208. $cantidad=$_POST ['cantidad'];  
  209. $codigo_plan=$_POST ['codigo_plan'];
  210. $trimestre=$_POST ['trimestre'];
  211.  
  212.  
  213. $curso=$_POST["curso1"];
  214.  
  215. $inicioh=$_POST ["hi"];
  216. $iniciom= $_POST ["mi1"] ;
  217. $finalh=$_POST ["hf"];
  218. $finalm= $_POST ["mf"];
  219. $martes=$_POST["m"];
  220. $miercoles=$_POST["mi"];
  221. $viernes=$_POST["v"];
  222. $sabado=$_POST["s"];
  223. $domingo=$_POST["d"];
  224. $jueves=$_POST["j"];
  225.  
  226. $c=1;
  227. foreach($curso as $a => $b)
  228. {
  229.    
  230. echo $curso[$a];
  231. if(isset($_POST['l'][$a]))
  232. {
  233. echo "x";
  234. } else { echo " ";}
  235.  
  236. }}
  237.  
  238. ?>
  239.  
  240. </body>
  241. </html>


Y osea si me sale que si presione 3 checkbox son 3 x seguidas la que me imprime, cuando deje alguna sin presionar. Por eso nose como hacer para capturar los presionados o no... T_T