Looking for tips on how to pre-select a checkbox (or anything besides a textfield) in a webform using URL parameters. We have pre-filled a textfield with URL params. We also found this article that explains how to pre-select a field created in webforms. The problem we have is pre-selecting a field brought in from CiviCRM. Does anyone have any tips or know of other nodes that will enable this? We are running Drupal 7 and CiviCRM 5.41.2.

1 Answer 1


I have done this via two different methods.

One method is using a 'pass-thru' field. I create a webform only text field (it does not need to exist in CiviCRM custom data) and have it pre-fill based on a URL parameter. Then I use conditionals to say if that text field equals "X" set this CiviCRM select field to "X". (I hide this field on the front-side of the form.)

The other method is jquery. You can load a javascript file through a custom module (or I've also used the Javascript injector https://www.drupal.org/project/js_injector). In jQuery you can get the URL parameters and then in some if statements adjust the value/property of fields on the form. Happy to expound if you need.

  • concur we have done via having a textfield (webform component) set via the URL and then the checkbox (civi field) set via conditionals from that textfield
    – petednz - fuzion
    Mar 21, 2022 at 21:30
  • That makes sense. Thanks for the help.
    – zach
    Mar 22, 2022 at 13:06
  • Since Civi Groups are treated as checkboxes in Webforms, I was hoping to add contacts to groups using this same method. I'm not having any luck using this method. Is there something different to try for adding to a group via URL parameters?
    – zach
    Mar 23, 2022 at 15:55
  • This is still possible although it might be clunkier than you'd like. You should be able to still use conditionals to say if pass-thru text field equals "staff" then Group(s) is set to the desired group ID, you can set multiple IDs using a comma. But I don't think this method will maintain any groups the contact is a part of (if you're using the groups in relation to a contact). This is why on occasion I've used some custom js - I have a little more control over appending values instead of replacing them.
    – RayWright
    Mar 23, 2022 at 21:34
  • I didn't think to try group IDs. We ended up having the conditional assign a tag and then used CiviRules to add them to a group based on that tag. I appreciate the follow up.
    – zach
    Mar 24, 2022 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.