jeudi 18 mai 2017

get value from checkbox but not the word from checkbox

I have two checkbox and under this when tick one of two checkbox I have two another option checkbox and another tick there will be text. The text will be value from the checkbox, how can I get the value from this checkbox? But the text I want to put are different sentence for each option checkbox selected not the word from checkbox. Did anyone know?

And my another problem is the checkbox not working if I do not tick the first checkbox.

<script type="text/javascript">
  function ShowHideDiv(Cat) {
    var dvCat = document.getElementById("bigCat");
    bigCat.style.display = Cat.checked ? "block" : "none";
  }
</script>

<label for="Cat">
    <input type="checkbox" id="Cat" onclick="ShowHideDiv(this)" /> Cat 
</label>

<script type="text/javascript">
  function ShowHideDiv2(Rabbit) {
    var bigRabbit = document.getElementById("bigRabbit");
    bigRabbit.style.display = Rabbit.checked ? "block" : "none";
  }
</script>

<label for="Rabbit">
    <input type="checkbox" id="Rabbit" onclick="ShowHideDiv2(this)" /> Rabbit 
</label>

<div id="bigCat" style="display: none">

  <label> 
    <input type="checkbox" id="bigSubCat" /> British shorthair 
</label>

  <label>
        <input type="checkbox" id="bigSubCat" /> Exotic Shorthair 
</label>

  <div id="bigRabbit" style="display: none">

    <label> 
    <input type="checkbox" id="bigSubRabbit" /> White Rabbit
</label>

    <label>
        <input type="checkbox" id="bigSubRabbit" /> Black Rabbit 
</label>



Aucun commentaire:

Enregistrer un commentaire