Help with hiding response option based on previous var value

  • inzideurhead
  • Born
  • Born
  • inzideurhead
  • Posts: 1

Post 3+ Months Ago

Hey Guys -

I'm working on creating a question that has a running total at the bottom of my screen. I was able to get this to work and is doing what I intended. The issue now is that I want to hide one of the variables based on response (=0 or =1; Boolean type response) from another question.

My current script is (doesnt include the hide functions):

**Assuming the variables from the other questions are v_5009 v_5010 v_5011 how can I hide the below items when these (<<<<) are ==1? Your help is much much appreciated!!


HTML Code: [ 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>
  • RockmanTV
  • Proficient
  • Proficient
  • RockmanTV
  • Posts: 348

Post 3+ Months Ago

By "variable" I'm assuming you're trying to hide sections of your form. Give the area of the form you're trying to hide a style of display:none:

[Grab the section of the form here].style.display='none';

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 57 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.