Im making a webform with a select list. If you chose a certain option in the select list I need a text input field be be revealed.

Can this be done by Drupal or should I write some jQuery to show / hide the input?


Update to a newer version of Webform where webform_conditional has been merged.

Description: This modules enhances the existing Conditional Rules of the Webform Module. It adds the ability to make components dependent on select components(i.e. listboxes, radio buttons, and checkboxes) that appear on the same page.

Important As of Webform version 7.x-4.0-alpha2 this module has been merged into Webform and is no longer necessary. The 7.x-2.x version of this module handles this upgrade. See: #1616376: Create Migration to Webform 4.x

Then when you make a webform node you will have additional local task labeled conditionals. Once you've added form fields to the webform -- you can set conditions using the administrative form found there.


I would do it using Javscript and hide the text field with CSS

Using a form_preprocess, add an attribute to fire your JS event.

This might be a helpful link: How to make form buttons call only javascript?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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