Ver Mensaje Individual
  #13 (permalink)  
Antiguo 15/03/2012, 07:29
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
Lo que pasa es que tienes muchos elementos con el mismo ID, dentro de tu while todos se llaman chk y txt esto esta MAL los ids deben ser unicos.
Aparte de eso, los indices de $row tambien estan mal, necesitan estar entre comillas dobles o simple. Y el </br> lleva una barra para finalizar la etiqueta :S
hola h2swider, se podria hacer algo asi ??

Código PHP:
while($row mysql_fetch_array($result)){
    
    echo 
"<tr>
        <td>$row[id_stock]</td>
        <td>$row[codigo]</td>
        <td>$row[descrip]</td>
        <td align=right>$$row[pre_min]</td>
        <td align=right>$$row[pre_may]</td>
        <td align=center>$row[disponibles]</td>
        <td><input id='chk[$row[id_stock]]' name='seleccion[]' type='checkbox' value=$row[id_stock] onChange='validarchk($row[id_stock]);'></td>
        <td style='border: none'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
        <td><input id='txt[$row[id_stock]]' name='text[$row[id_stock]]' disabled='disabled' type='text' style='width: 60'></td>  
        </tr>"
;
        
    
$i++;
}


<
script>
 
function 
validarchk(id){
var 
chk document.getElementById('chk');
var 
txt document.getElementById('txt');
if(
chk[id].checked){
    
txt[id].disabled='';
}else{
    
txt[id].value='';
    
txt[id].disabled='disabled';
}
}
</script> 
osea pasarle el $row[id_stock] para asi hacer un nombre compuesto el cual no se repetira. pero nose como hacerlo ya que nose javascript