Donation Form - hiding field depending on checkbox field

Options
Hello everyone!
We have a donation form that is used for corporate gifts. It has a checkbox to 'make this gift on behalf of an organization' and I'm trying to figure out if it is possible to hide another field based on if that box is checked or not? I know it is possible with some java script but I am not that skilled with coding so wanted to reach out to all of you and see if anybody has done this before. Here is the form I'm working on: https://secure3.convio.net/fandf/site/Donation2?df_id=3015&mfc_pref=T&3015.donation=form1

Basically I want to hide the 'job title' field if the ' Make this gift on behalf of an organization' box is unchecked. Any help is appreciated, thanks!
Tagged:

Comments

  • You can toggle the Job Title field with something like this:


    if (document.getElementById("organization-name-visiblename").checked == true) {

    document.getElementById("donor_occupation_row").style.display = "block";

    } else {

    document.getElementById("donor_occupation_row").style.display = "none";

    }
  • You also need to add an event listener to the checkbox in order to actually fire Daryl's code when it gets changed.

    <script>
    document.getElementById("organization-name-visiblename").addEventListener("click", function() {
    if (document.getElementById("organization-name-visiblename").checked == true) {
    document.getElementById("donor_occupation_row").style.display = "block";
    } else {
    document.getElementById("donor_occupation_row").style.display = "none";
    }
    });
    </script>

Categories