When I click a webform link, I want one of the checkbox checked. I've set already set up the default value for that checkbox as %get[foo] in Webform.

I tried:

a href="node/34?foo=checked"

a href="node/34?foo=selected"

a href="node/34?foo=1"

a href="node/34?foo[]=1"

Am I missing something?


5 Answers 5


Webform provides this functionality by itself.

  1. Define in your checkbox field a default value:


custom key capture

  1. The url will be:


webform url capture


Use [current-page:query:foo] in Default Value field and set query string to node/1?foo=1,2 and it will work.

Installing Tokens module will show you some values you can use in your default value field.


Keep in mind that, at the moment of writing, there's an issue with tokens and the Options Element module in Webform.


This feature is not directly available on Webform module. You've to implement some code to prefill the form fields.

A simple method is to write some JS which reads the URL parameters and set the values to the corresponding fields.

There are many ways to implement this code. This is an example of JavaScript code:

var current_url = window.location.href;
if (current_url.indexOf('foo=') > 0){
  $('#field-id').val(current_url.substr(current_url.indexOf('foo=') + 4));

At first the script get the current url and if the "foo" parameter is found, then the value will be loaded and used to set the #field-id value. #field-id is the id of the input field on the webform. 4 is the length of "foo=".

If you have many parameters you can use


method which returns an array with all the parameters.

  • I know my method works because I grabbed the value of foo for a text-field. It just I don't know how to pass a value for checkbox. TQ for taking time for typing out the JS code. It just I'm reluctant to enable phpcode in my webform for fear of being compromised.
    – Jessica K
    Commented Jan 5, 2014 at 15:45

You can use the Prepopulate module which autofills your fields. Here is a quote about it (from the module's project page):

... allows fields in most forms to be pre-populated from the $_REQUEST variable.

For example, the following URL,

http://www.example.com/node/add/blog?edit[title]=this is the title

will automatically fill the Title field on a new blog post with the words "this is the title". Any field can be prepopulated this way, including taxonomy and CCK fields. You can prepopulate more than one field at a time as well. Prepopulate is excellent for creating bookmarklets.

  • This is not what I want. I'm on D7.
    – Jessica K
    Commented Jan 7, 2014 at 10:25
  • The module also have d7 version. It's currently in dev version but you can use it I think.
    – gfarishyan
    Commented Jan 7, 2014 at 19:06

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.