Ver Mensaje Individual
  #15 (permalink)  
Antiguo 15/03/2012, 07:41
tesistas
 
Fecha de Ingreso: septiembre-2010
Mensajes: 74
Antigüedad: 13 años, 7 meses
Puntos: 1
Respuesta: quiero habilitar textbox al tildar checkbox

Cita:
Iniciado por h2swider Ver Mensaje
aquí tienes algo que te podría servir. Rehice todo tu codigo, espero que sepas agradecerlo.

Saludos

Código PHP:
Ver original
  1. <?php
  2. include_once 'lib.php';
  3.  
  4. $conexion = mysql_connect($dbhost, $dbuser, $dbpassword);
  5. mysql_select_db($database, $conexion);
  6. $result = mysql_query("SELECT id_stock, codigo, descrip, pre_min, pre_may, disponibles  FROM stock where activo = '1'", $conexion);
  7. ?>
  8. <form name="borrar" method="post" action="vender_prod.php">
  9.     <table border="2">
  10.         <tr>
  11.             <th>ID</th>
  12.             <th>Codigo</th>
  13.             <th>Descrip</th>
  14.             <th>Prec.Min</th>
  15.             <th>Prec.May</th>
  16.             <th>Disponibles</th>
  17.             <th></th>
  18.             <th style='border: none'></th>
  19.             <th>Cantidad</th>
  20.  
  21.         </tr>
  22.         <?php
  23.         $i = 0;
  24.         while ($row = mysql_fetch_array($result)) {
  25.             ?>
  26.             <tr>
  27.                 <td><?php echo $row['id_stock'] ?></td>
  28.                 <td><?php echo $row['codigo'] ?></td>
  29.                 <td><?php echo $row['descrip'] ?></td>
  30.                 <td align="right"><?php echo $row['pre_min'] ?></td>
  31.                 <td align="right"><?php echo $row['pre_may'] ?></td>
  32.                 <td align="center"><?php echo $row['disponibles'] ?></td>
  33.                 <td><input id="chk_<?php echo $i ?>" name="seleccion[]" type="checkbox" value="<?php echo$row['id_stock'] ?>" class="chk"/></td>
  34.                 <td style="border: none"></td>
  35.                 <td><input id=txt_<?php echo $i ?>" name="text[<?php $row['id_stock'] ?>]" disabled="disabled" type="text" style="width: 60" class="txt"/></td>  
  36.             </tr>
  37.  
  38.             <?php
  39.             $i++;
  40.         }
  41.         ?>
  42.     </table>
  43.     <br />
  44.     <input type="submit" name="submit" value="enviar">
  45. </form>
  46.  
  47. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  48. <script type="text/javascript">
  49.    
  50.     $(document).ready(function(){
  51.        
  52.         $(".chk").change(function(){
  53.             var comentario = $( '.txt', $( this ).parents ( 'tr' ) );
  54.             if( $(this).is(':checked')){            
  55.                 comentario.removeAttr('disabled');
  56.             } else {
  57.                 comentario.attr('disabled', true);
  58.             }
  59.         });
  60.     });
  61.    
  62. </script>
Anduvo impresionante, nunca nadie me dio una mano tan grande. GRACIAS h2swider, SOS LO MAXIMO!!