Drupal 7 Webform : How to display/hide some fields based on other select option fields
19,871
Look into the Webform Conditional module. There's a demo here https://www.youtube.com/watch?v=7uxfqJr6K6U which can show you what it's capable of to verify that this is what you're looking for.
Author by
rinku
Updated on June 04, 2022Comments
-
rinku almost 2 years
I am using Drupal -7 and webform .. I need to show/hide different fields based on on select option. for eg. select option "Project type"
if I select "Project type" as A => I want to display field1, field2 and select-option3
if I select "Project type" as B => I will display only field3, field4 and select-option4
rest all fields will be displayed in both the cases.
I cant use webform conditional as it doesn't work with select Other. Can anyone help me with the code either "Hook" or "Markup" field in webform.
-
rinku almost 13 years@mmc: Actually I had seen this earlier but it is not compatible with the "Select (or Other)" module. and I am using this module already.
-
rinku almost 13 yearscan you suggest some other way of doing it?
-
nmc almost 13 years@rohit bhatnagar: other way is to write your own javascript to toggle showing/hiding the displays according to your logic.
-
mikewink almost 13 yearsWell if you are familiar with the Form API #states system in D7 you can do it in your own custom module. Have a look at: randyfay.com/states for a gentle introduction.
-
rinku almost 13 years@mnc: how do I add my own java script in webform code? can you please guide me?
-
rinku almost 13 years@mikewink: I have a custom module of mine. but I dont know How can I change one component based on other.. can you give me some code snippet for a scenario where component "task_title" is hidden based on selecting "BAU" in "type_of_work" select.