Display dropdownlist selected value

joyanta sen asked on May 23, 2018 19:18

Hi, I have following requirement, I need to display the dropdownlist selected value into the textbox field. Both are the custom fields under the User module and the Value and Text field of dropdown are string.

Could you please let me know how to achieve that.

Thanks

Recent Answers


Rui Wang answered on May 23, 2018 22:25

  • Create the field for drop down (e.g. "Options"), set form control to drop down, and create the list. Also, at the very bottom of the properties, check "Has depending field".
  • Create the field for display (e.g. "OptionDisplay"), at the very bottom check "Depends on another field". For the display, you have two options to get the updated value. 1 - use a label form control, and for the "output format" property, click the black triangle and enter macro {% Options.Value #%}. 2 - If you want to use text box, you can only display the text via "Watermark" and click on the black triangle next to watermark property and enter macro {% Options.Value #%}
0 votesVote for this answer Mark as a Correct answer

joyanta sen answered on May 23, 2018 23:06

Hi Rui,

Thanks for the reply. But I need to save the value in the database, which is not happening while I am following the both the options.

Since I have 2 fields Label and a TextBox, in the Label I am displaying the Id (as per the option you have provided) and in the TextBox I need to display the selected Text in the dropdown, how will get that?

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on May 23, 2018 23:24

0 votesVote for this answer Mark as a Correct answer

joyanta sen answered on May 23, 2018 23:43

SO this is not possible with macros, I need to write Jquery to achieve that..

Thanks..

0 votesVote for this answer Mark as a Correct answer

joyanta sen answered on May 24, 2018 00:38

Is there any way I can get the dropdownlist's selected TextField value(not ValueField) using macros?

Thanks.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 24, 2018 01:10 (last edited on May 24, 2018 01:26)

If I may propose there is a good javaScript control Selectize which is essentially combination of text box and drop down and it allows you to do multiple select. I suggest you make a your own form control out of it.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on May 24, 2018 15:34

jouanta, macros are server side code. what you are trying to do is client side.

0 votesVote for this answer Mark as a Correct answer

joyanta sen answered on May 24, 2018 17:22

Ok..Thanks for the information. In that case, Is there any way I can get the selected Text value in server side Event, instead of querying to the database and get the text based on the value selected?

For ex: I have Employers dropdown as a Custom field in the User module. Where I am displaying the Employee name as text field and the Employee Id as Value field. On selection of some Employee is it possible to get the Employee Name selected in Insert_Before event at server side?

Thanks.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on June 6, 2018 14:27

@joyanta I was answer another question and thought this may be a work around for you. you can use another drop down list from control for the second field, and set the Data Source to {% Options.Value %} the drop down list control does have update event client side. The only down side is it looks like drop with just 1 option, which could be good as visitor cannot change the text.

0 votesVote for this answer Mark as a Correct answer

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