Código :
<html> <head> <title>Untitled</title> </head> <script> function activar(){ alert('entre a funcion'); var inputTexto = document.miFormulario.precio; var checkCaja = document.miFormulario.existe; checkCaja.checked=false; if(inputTexto.value == ''){ checkCaja.checked=false; }else{ checkCaja.checked=true; } } </script> <body> <form name="miFormulario"> <input type="checkbox" name="existe"> <input type="text" name="precio" value="" onchange="activar()"> <br/> </form> </body> </html>
El problema es que son un array de productos que jalo de una base de datos y el nombre final de cada check queda con la id
Código :
<form name="miFormulario"> <input type="checkbox" name="existe1"> <input type="text" name="precio1" value=""onchange="activar()"> <br/> <input type="checkbox" name="existe2"> <input type="text" name="precio2" value=""onchange="activar()"> <br/> <input type="checkbox" name="existe3"> <input type="text" name="precio3" value=""onchange="activar()"> </form>
como lo implemento este script con la id en dicho array [/code]