title: how to concisely write this javascript to show/hide a list of elements?
body: <p>How to write this type of code in loop? Actually I don't want to write the same same line again and again, Is their any way to compress this code? can we write this code in loop?</p>
  
  <pre><code>function showCandidates()
  {document.getElementById("cand9").style.display="block";
  document.getElementById("cand10").style.display="block";
  document.getElementById("cand11").style.display="block";
  document.getElementById("cand12").style.display="block";
  document.getElementById("cand13").style.display="block";
  document.getElementById("cand14").style.display="block";
  document.getElementById("cand15").style.display="block";
  document.getElementById("hide_cand").style.display="block";
  document.getElementById("view_cand").style.display="none";
  }
  
  function hideCandidates()
  {document.getElementById("cand9").style.display="none";
  document.getElementById("cand10").style.display="none";
  document.getElementById("cand11").style.display="none";
  document.getElementById("cand12").style.display="none";
  document.getElementById("cand13").style.display="none";
  document.getElementById("cand14").style.display="none";
  document.getElementById("cand15").style.display="none";
  document.getElementById("hide_cand").style.display="none";
  document.getElementById("view_cand").style.display="block";
  }
  </code></pre>