Foros del Web » Programando para Internet » Javascript »

funcion de campos

Estas en el tema de funcion de campos en el foro de Javascript en Foros del Web. hola a todos quisiera hacerles una consulta son novato. tengo este código con estas funciones @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original < script language ...
  #1 (permalink)  
Antiguo 04/05/2012, 12:49
Avatar de mexbale  
Fecha de Ingreso: septiembre-2010
Ubicación: Iztapalapa
Mensajes: 146
Antigüedad: 13 años, 7 meses
Puntos: 1
funcion de campos

hola a todos quisiera hacerles una consulta son novato.

tengo este código con estas funciones

Código Javascript:
Ver original
  1. <script language="JavaScript" type="text/javascript">
  2. function activaEstado(iden) //funcion para activar los campos
  3. {
  4. var elhtml2 = document.getElementById(iden);
  5. var elhtml = iden;
  6. if(elhtml2.style.display == 'none'){
  7. elhtml2.style.display = 'block';}
  8. else {elhtml2.style.display = 'block';}
  9. }
  10. </script>
  11. <script language="JavaScript" type="text/javascript">
  12. function desactivaEstado(iden) //funcion para desactivar los campos
  13. {
  14. var elhtml2 = document.getElementById(iden);
  15. var elhtml = iden;
  16.  
  17.  
  18.  
  19.  
  20. elhtml2.style.display = 'none';
  21. elhtml2.value="";
  22. }
  23. </script>
Código Javascript:
Ver original
  1. <style type="text/css">
  2. <!--
  3. #D01 {    border: solid 1px #333333;
  4. }
  5. #T01 {    border: solid 1px #333333;
  6. }
  7. -->
  8. </style>
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Prueba</title>
  5. </head>
  6. <table width="100%" id="T01">
  7.   <tr id="R01_01">
  8.     <td id="D01"><strong>01</strong></td>
  9.     <td id="D01"><div align="center">
  10.       <input name="S01P0101_1" type="text" id="S01P0101_1" size="2" maxlength="2" />
  11.     </div></td>
  12.     <td id="D01"><div align="center">
  13.       <input name="S01P0102_1" type="text" id="S01P0102_1" size="2" maxlength="2" />
  14.     </div></td>
  15.     <td id="D01"><div align="center">
  16.       <input name="S01P0103_1" type="text" id="S01P0103_1"maxlength="150" />
  17.     </div></td>
  18.     <td id="D01"><div align="center">
  19.       <input name="S01P0201_1" type="text" id="S01P0201_1" size="2" maxlength="2" />
  20.     </div></td>
  21.     <td id="D01"><div align="center">
  22.       <input name="S01P0202_1" type="text" id="S01P0202_1" size="2" maxlength="2" />
  23.     </div></td>
  24.     <td id="D01"><div align="center">
  25.       <input name="S01P0301_1" type="text" id="S01P0301_1" size="1" maxlength="1" />
  26.     </div></td>
  27.     <td id="D01"><div align="center">
  28.       <input name="S01P0302_1" type="text" id="S01P0302_1" size="1" maxlength="1" />
  29.     </div></td>
  30.     <td id="D01"><div align="center">
  31.       <input name="S01P04_1" type="text" id="S01P04_1"maxlength="150" />
  32.     </div></td>
  33.     <td id="D01"><div align="center">
  34.       <input name="S01P0501_1" type="text" id="S01P0501_1" size="2" maxlength="2" />
  35.     </div></td>
  36.     <td id="D01"><div align="center">
  37.       <input name="S01P0502_1" type="text" id="S01P0502_1" size="4" maxlength="4" />
  38.     </div></td>
  39.   </tr>
  40. </body>
  41. </html>

y quisiera que cuando en el campo S01P0201_1=6 cualquier respuesta en el campo S01P0301_1 oculte los campos S01P04_1, S01P0501_1 y S01P0502_1

como lo podría hacer esto

espero que me puedan ayudar de ante mano les doy las gracias
que tengan un buen dia
suerte
  #2 (permalink)  
Antiguo 04/05/2012, 14:46
Avatar de lukas4  
Fecha de Ingreso: octubre-2008
Ubicación: frente al pc
Mensajes: 496
Antigüedad: 15 años, 6 meses
Puntos: 12
Respuesta: funcion de campos

podrías usar un onchange:

Código HTML:
Ver original
  1. <input name="S01P0201_1" type="text" id="S01P0201_1" size="2" maxlength="2" onchange="ocultar()"/>

y ya en la función pones algo así:

Código Javascript:
Ver original
  1. x=document.getElementById("S01P0201_1").value;
  2. if(x==6){
  3.    document.getElementById("S01P04_1").style.display="none";
  4.    document.getElementById("S01P0501_1").style.display="none";
  5.    document.getElementById("S01P0502_1").style.display="none";
  6. }

revisa este link, puede que te sirva: ejemplo
__________________
http://situcomo.blogspot.com
Karma is a Bitch... they said

Etiquetas: campos, funcion, html, input
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:59.