Ayuda para ocultar la opción de respuesta basada en el valor anterior de var

  • inzideurhead
  • Born
  • Born
  • No Avatar
  • Registrado: Sep 17, 2011
  • Mensajes: 1
  • Status: Offline

Nota Septiembre 17th, 2011, 7:45 pm

Hola chicos -

Im trabajando en la creación de una pregunta que tiene una ejecución total en la parte inferior de la pantalla. Yo era capaz de conseguir que funcione y está haciendo lo que me proponía. El problema ahora es que quiero ocultar una de las variables en función de respuesta (= 0 o = 1; Respuesta de tipo Boolean) desde otra pregunta.

Es mi script actual (no incluye las funciones de ocultar):

** Asumiendo las variables de las otras preguntas son v_5009 v_5010 v_5011 ¿cómo puedo ocultar los artículos a continuación cuando estos (<<<<) son == 1? Su ayuda es muy apreciada!!


HTML Código: [ Select ]
<script language="JavaScript">
<!--
var max=300;
 
function ViewSum(SumId)
{
var nCounter;
var nSum=0;
var MyInputCollection=document.getElementsByTagName("input");
 
for (nCounter=0;nCounter<MyInputCollection.length;nCounter++)
{
if (MyInputCollection[nCounter].getAttribute("Id")==SumId)
{
if (MyInputCollection[nCounter].value!=""
 
&& parseInt(MyInputCollection[nCounter].value) != NaN)
{
nSum += parseInt(MyInputCollection[nCounter].value);
}
else
{
nSum = nSum;
}
}
}
if(nSum <= max)
{
document.getElementById("Result").innerHTML=nSum;
}
}
-->
</script>
 
 
<div id="questiontable"><div class="qt143"><div id="qnameq4920"><table cellpadding="0" cellspacing="0" width="100%" border="0" bordercolor="green">
 <tr>
  <td class="questiontext"><a name="1"> </a>And what percentage of your yard would you say is covered by...
 
    </td>
 </tr>
  <tr>
  <td class="instruction">
      <br/>*Please note that the total must equal 100%.  Please use only whole numbers (no decimal points). Mahalo.
<br/><br/>
  </td>
 </tr>
  </table>
<table border="0" class="answertable" bordercolor="purple" cellspacing="0" cellpadding="0">
 <tr>
  <td class="answertext" ><label for="v_55">Grass, vegetation, or trees&nbsp;&nbsp;</label></td>
<td class="answerelement" style="text-align:left;">
<nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_55" value="" size="3" maxlength="3"  />
 </nobr></td>
  <td class="answerend"  width="100%" align="right">&nbsp;</td>
 </tr>
 <tr>
  <td class="answertext2" ><label for="v_56">Dirt or gravel patches with no vegetation&nbsp;&nbsp;</label></td>
<td class="answerelement2" style="text-align:left;">
<nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_56" value="" size="3" maxlength="3"  />
 </nobr></td>
  <td class="answerend2"  width="100%" align="right">&nbsp;</td>
 </tr>
 <tr>
  <td class="answertext" ><label for="v_57">Pavement&nbsp;&nbsp;</label></td>
<td class="answerelement" style="text-align:left;">
<nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_57" value="" size="3" maxlength="3"  />
 </nobr></td>
  <td class="answerend"  width="100%" align="right">&nbsp;</td>
 </tr>
<tr>
<td><b>TOTAL:</b></td>
<td Id="Result"></td>
<td></td>
</tr>
 
</table>
</div></div></div>
  1. <script language="JavaScript">
  2. <!--
  3. var max=300;
  4.  
  5. function ViewSum(SumId)
  6. {
  7. var nCounter;
  8. var nSum=0;
  9. var MyInputCollection=document.getElementsByTagName("input");
  10.  
  11. for (nCounter=0;nCounter<MyInputCollection.length;nCounter++)
  12. {
  13. if (MyInputCollection[nCounter].getAttribute("Id")==SumId)
  14. {
  15. if (MyInputCollection[nCounter].value!=""
  16.  
  17. && parseInt(MyInputCollection[nCounter].value) != NaN)
  18. {
  19. nSum += parseInt(MyInputCollection[nCounter].value);
  20. }
  21. else
  22. {
  23. nSum = nSum;
  24. }
  25. }
  26. }
  27. if(nSum <= max)
  28. {
  29. document.getElementById("Result").innerHTML=nSum;
  30. }
  31. }
  32. -->
  33. </script>
  34.  
  35.  
  36. <div id="questiontable"><div class="qt143"><div id="qnameq4920"><table cellpadding="0" cellspacing="0" width="100%" border="0" bordercolor="green">
  37.  <tr>
  38.   <td class="questiontext"><a name="1"> </a>And what percentage of your yard would you say is covered by...
  39.  
  40.     </td>
  41.  </tr>
  42.   <tr>
  43.   <td class="instruction">
  44.       <br/>*Please note that the total must equal 100%.  Please use only whole numbers (no decimal points). Mahalo.
  45. <br/><br/>
  46.   </td>
  47.  </tr>
  48.   </table>
  49. <table border="0" class="answertable" bordercolor="purple" cellspacing="0" cellpadding="0">
  50.  <tr>
  51.   <td class="answertext" ><label for="v_55">Grass, vegetation, or trees&nbsp;&nbsp;</label></td>
  52. <td class="answerelement" style="text-align:left;">
  53. <nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_55" value="" size="3" maxlength="3"  />
  54.  </nobr></td>
  55.   <td class="answerend"  width="100%" align="right">&nbsp;</td>
  56.  </tr>
  57.  <tr>
  58.   <td class="answertext2" ><label for="v_56">Dirt or gravel patches with no vegetation&nbsp;&nbsp;</label></td>
  59. <td class="answerelement2" style="text-align:left;">
  60. <nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_56" value="" size="3" maxlength="3"  />
  61.  </nobr></td>
  62.   <td class="answerend2"  width="100%" align="right">&nbsp;</td>
  63.  </tr>
  64.  <tr>
  65.   <td class="answertext" ><label for="v_57">Pavement&nbsp;&nbsp;</label></td>
  66. <td class="answerelement" style="text-align:left;">
  67. <nobr><input type="text" onblur="ViewSum('SumA');" id="SumA" name="v_57" value="" size="3" maxlength="3"  />
  68.  </nobr></td>
  69.   <td class="answerend"  width="100%" align="right">&nbsp;</td>
  70.  </tr>
  71. <tr>
  72. <td><b>TOTAL:</b></td>
  73. <td Id="Result"></td>
  74. <td></td>
  75. </tr>
  76.  
  77. </table>
  78. </div></div></div>
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Septiembre 17th, 2011, 7:45 pm

  • RockmanTV
  • Proficient
  • Proficient
  • No Avatar
  • Registrado: Oct 12, 2004
  • Mensajes: 348
  • Status: Offline

Nota Septiembre 22nd, 2011, 3:05 pm

"Variable" Im asumiendo que intenta ocultar secciones del formulario. Dar el área del formulario está intentando ocultar un estilo de visualización: ninguno:

[Grab la sección del formulario aquí].style.display = "none";

Publicar Información

  • Total de mensajes en este tema: 2 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 110 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC