mercredi 27 septembre 2017

JQuery if x Checkboxes checked change link

i need a jquery script. I have three Chechboxes and two links. If all three checkboxes are checked, it show link 1. If only 1 or 2 checkboxes are checked, it show link 2.

Thanks in advance.

      <div>
     <section title=".agreeCheckbox">
        <div class="agreeCheckbox">
          <input type="checkbox" value="None" id="agreeCheckbox1" name="agreeCheckbox" unchecked onchange="toggleLink(this);"/>
          <label for="agreeCheckbox"></label>
        </div>
      </section>
     </div> 

    <div style="padding-top:100px;">
     <section title=".agreeCheckbox">
        <div class="agreeCheckbox">
          <input type="checkbox" value="None" id="agreeCheckbox" name="agreeCheckbox" unchecked onchange="toggleLink(this);"/>
          <label for="agreeCheckbox"></label>
        </div>
      </section>
     </div> 

<div style="padding-top:100px;">
     <section title=".agreeCheckbox">
        <div class="agreeCheckbox">
          <input type="checkbox" value="None" id="agreeCheckbox" name="agreeCheckbox" unchecked onchange="toggleLink(this);"/>
          <label for="agreeCheckbox"></label>
        </div>
      </section>
     </div>  

    <p><a href="exmaple.com" id="agreeLink" style="display:none;">Jetzt bewerben!</a><a href="none.com" id="dontagreeLink" style="display:inline;">Jetzt bewerben!</a></p>


    <script type="text/javascript">function toggleLink(checkBox)
    {
        var link = document.getElementById("agreeLink");

        if (checkBox.checked)
            link.style.display = "inline";
        else
            link.style.display = "none";

        var link = document.getElementById("dontagreeLink");

        if (checkBox.checked)
            link.style.display = "none";
        else
            link.style.display = "inline";
    }
     </script>




Aucun commentaire:

Enregistrer un commentaire