Answers.Body: <p>I have done this via two different methods.</p>
  <p>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 &quot;X&quot; set this CiviCRM select field to &quot;X&quot;. (I hide this field on the front-side of the form.)</p>
  <p>The other method is jquery. You can load a javascript file through a custom module (or I've also used the Javascript injector <a href="https://www.drupal.org/project/js_injector" rel="nofollow noreferrer">https://www.drupal.org/project/js_injector</a>). 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-21T21:30:48.080Z
Answers.Text: 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
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-22T13:06:05.593Z
Answers.Text: That makes sense. Thanks for the help.
Answers.UserDisplayName: zach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-23T15:55:38.747Z
Answers.Text: 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?
Answers.UserDisplayName: zach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-23T21:34:51.753Z
Answers.Text: 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.
Answers.UserDisplayName: RayWright
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-24T13:41:36.773Z
Answers.Text: 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.
Answers.UserDisplayName: zach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-21T21:10:23.210Z
Answers.LastActivityDate: 2022-03-21T21:10:23.210Z
Answers.UserDisplayName: RayWright
Body: <p>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 <a href="https://drupal.stackexchange.com/questions/246743/how-can-i-set-a-webforms-field-value-by-query-parameter">this article</a> 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.</p>
  
Tags: <drupal><webform-civicrm><drupal-7>
Title: Is it possible to pre-fill a checkbox field using URL parameters? Fields are from CiviCRM
ThreadText: # Is it possible to pre-fill a checkbox field using URL parameters? Fields are from CiviCRM
  
  (Asked by: username_0 on 2022-03-21)
  
  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](https://drupal.stackexchange.com/questions/246743/how-can-i-set-a-webforms-field-value-by-query-parameter) 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.
  
  **Tags:** drupal, webform-civicrm, drupal-7
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-03-21. Score: 2 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_2**: 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  
  > **username_0**: That makes sense. Thanks for the help.  
  > **username_0**: 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?  
  > **username_1**: 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.  
  > **username_0**: 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.  
  
  ---
  
  