mercredi 15 juillet 2015

show one div and hide another div onclick of list of checkboxes

div1 = Top 10 Listings div2 = Send Selected

am looking for functionality that will be having n no. of contacts each with a checkbox when checkbox checked div2 has to be displayed otherwise div1 should have to be displayed... Am entirely new to this forum sry if my qtn is confusing below is what I've achieved upto now... http://ift.tt/1CDPq8E

now checkbox is working as a toggle but I need that div2 to display if one/multiple checkbox checked it should stay at div2

at default it should have to show div1

if no checkbox is checked then it have to show div1

<script>
  x=false;
  function Check(){
    if(x){    
      document.getElementById("div1").style.display='inline';
      document.getElementById("div2").style.display='none';
      x=false;
    }
    else{
      document.getElementById("div1").style.display='none'; 
      document.getElementById("div2").style.display='inline';   
      x=true;    
    }
  }
</script>
<div>
  <a href="#" id="div1"> <h2>Top 10 Listings</h2> </a>
  <a href="#" id="div2" style="display:none"> <h2>Send Selected</h2> </a>
</div>
<div class="contacts">
  Contact 1<input type="checkbox" id="check" onclick="Check()">
  <br>
  Contact 2<input type="checkbox" id="check" onclick="Check()">
  <br>
  Contact 3<input type="checkbox" id="check" onclick="Check()">
</div>




Aucun commentaire:

Enregistrer un commentaire