Toggle visibility of a field on drop down selection

Fahad Ahmed asked on December 6, 2018 06:23

Hi ,

I have a drop down list that binds to an SQL source. Inthe Kentico , I am trying to do something as follows:

" Trying to make a macro in kentico , so if the drop down value is let's say A , the text field will be visible beneath it, else the text filed will remain invisible".

I am in a situation where I can not do this on the clinet(asp.nnet mvc) end and write some script .

Is there any reasonable way in kentico that I can write a macro for this , and then read the macro at the client (asp.net mvc) ? I am using Kentico version 11.

Requested to guide me , if I am thinking to achieve this task in an incorrect manner.

Cheers.

Recent Answers


David te Kloese answered on December 6, 2018 14:41

Well since you have a separate MVC application Kentico won't know what's going on at that end.

So you'll have to create some trigger that retrieves additional data as soon as something changes in your Dropdown.

Is it a Form you manage in the Kentico Forms module?

0 votesVote for this answer Mark as a Correct answer

Fahad Ahmed answered on December 6, 2018 23:55 (last edited on December 10, 2019 02:31)

Hi David ,

Thanks for the feedback.Yes I have a separate application for client which is an asp.net mvc app and is a form (BizForm). I was wondering if something like this could work as the macro for the field that need's to be invisible or visible based on the selection of drop down this is the field that depeneds on another field, which is the drop down:

Fields.Individual_Organisation.Value == "Organisation"

I tried reading this macro in c# code ,

 var jsEval = field.PropertiesMacroTable["visiblemacro"].ToString();

While dedugging this is what I am able to see :

{%Fields.Individual_Organisation.Value == "Organisation"|(identity)GlobalAdministrator%}

Why can't I get thee macro smiply as the macro that I provide? this user and hash always appends when I read the visiblemacro propoerty. I was thinking if I could use any HTML 5 atributes in this way and add some javascript at runtime to the drop down change to do the trick. I am new to kentico , so any help or guidance will be appreciated. Is there any setting that I need to do , to read the propoerty so I could get the correct macro text , without the user and hash string?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.