I have a standard contact page created using webform, which has a set of radio buttons.

Is it possible to change the pre-selected radio option based on the referring page?

4 Answers 4


I would add ?selectValue=yourvalue to the links pointing to your webform.

Then, create a template node--webform.tpl.php, check if i'm in the correct webform with the $node object and if $_GET['selectValue'] is set. Then use jQuery to select my radio button.

It might not by the perfect solution, but it's clearly a way out!

  • This solution needs jQuery enabled, there is better approaches on this topic like tokens or just do a custom form_alter
    – jorgetutor
    Aug 5, 2014 at 17:09

With Webform you can pre-populate form default values via the url with tokens:

Setting Default Values from the URL (7.x-3 and earlier)

The %get[key] supported by Webform allows form values to be populated from the URL.

Setting Default Values from the URL (7.x-4)

To set the default values of a component to use either:

Query Format: For urls formatted like http://example.com/node/120?key=bar use [current-page:query:key] to return key value.,

Args Format: For urls formatted like http://example.com/node/120/key use [current-page:url:args:2] to return key.

Taken verbatim from webform docs


In Drupal 8 using Webforms module you can do the following:


Add: '#default_value': 'Yes'

To the radio button defined in the YML.


When you are adding new field in webform, select "Select option" in the type of field. After that you will get a field configuration page. In field configuration page you will see 3rd option as default value. You can put default value for that field.

  • When I set the default value there, it is the same no matter what page you come from. I want the default option to change. Eg. if clicking the webform link from the sales page, then the sales enquiry radio option is pre-selected by default; if clicking webform from about us page, then general enquiry option is pre-selected.
    – Rooneyl
    Jan 12, 2012 at 8:23

Your Answer

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

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