Donation form tribute box checked by default

Options
We have a campaign that I wanted the 'this gift is a tribute' box checked by default. Blackbaud doesn't provide an option for that so I figured the below out and thought I'd share in case anyone else might find it useful. Obviously you would have to edit some stuff to make it work for your form. I'm sure someone better than me can do better but it works! You would just need to put your forms code in and then paste it in like usual.


<div id="bbox-root">

<script type="text/javascript">

       window.bboxInit = function () {

                    bbox.showForm('FORM_CODE_HERE');

       };

(function() {

  var e = document.createElement('script');

  e.async = true;

  e.src = 'https://bbox.blackbaudhosting.com/webforms/bbox-min.js';

  document.getElementsByTagName('head')[0].appendChild(e);


  setTimeout(checkCheckbox, 10);


  function checkCheckbox() {

    if (document.getElementById('bboxdonation_tribute_chkTributeGift')) {

      // element found, check box

      document.getElementById('bboxdonation_tribute_chkTributeGift').checked = true;

      document.getElementById('bboxdonation_tribute_chkTributeGift').dispatchEvent(new Event('change'));

    } else {

      // wait a little longer

      setTimeout(checkCheckbox, 10);

    }

  }


}());

</script>

</div>
Tagged:

Comments

  • Austen Brown
    Austen Brown ✭✭✭✭✭
    Ninth Anniversary Facilitator 4 Name Dropper Photogenic
    Hi Joshua Farquhar‍ - This is fantastic!  Quick question, do you know what the monthly opt-in box would be in the code? 
  • I don't.


    You can find the name of an element by going to the page (using Chrome) and right clicking on the element in question and clicking 'Inspect'. It should look like the image:
    41c3f021ffbbfd80f5bb8ebf4abf7d06-huge-im


    Point of interest....the way the little hack I did works is by reloading the form once the named element is found. This causes the page to 'pop' to that element. In our use case having the box checked was worth that minor inconvenience, but yours might differ.
  • Austen Brown
    Austen Brown ✭✭✭✭✭
    Ninth Anniversary Facilitator 4 Name Dropper Photogenic
    Hi Joshua Farquhar‍ - Thank you so much! It works! This has made my week!
  • Awesome idea Joshua! Thanks for sharing.

Categories