Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Fill text field with multi selections from drop down list

9 years 3 months ago #268607 by gjvanwijk63
I populate a multi selection Query drop down list with occupations (from a table). This works fine. They show up and I can select multiple values. What I want to do is populate a textbox (field) with the values that are selected in the dropdown list. Is that possible?

Thx in advance

Gert-Jan

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #268630 by krileon
Yes, it's possible. However, why would you need to do this? What are you trying to achieve by doing this? There maybe a better alternative. For example if you just want to display them in another location you can substitute the field into a Custom HTML field without having to be concerned with double storage.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

9 years 3 months ago #268650 by gjvanwijk63
Thx for your reply. How does your solution work. I'm a newbie as you may already have noticed....

thx

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #268654 by krileon
Create a Custom HTML field then supply the below substitution usage to its Description (toggle source view to ensure it doesn't get escaped by the editor).

[cb:userfield field="FIELD_NAME" /]

Replace FIELD_NAME with the actual name of the field. See the below for tutorial on further substitution usage.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

9 years 3 months ago #268656 by gjvanwijk63
Thx again.

I don't see how this would work with multiple selections.

The thing is I don't want to storage the values in the database again, it's just another way of showing them. Instead of a drop down list where it's not handy to look for which items are selected, I want the selected item to be dynamically displayed in another field (a textbox is most likely).

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
9 years 3 months ago #268660 by krileon
You can use substitution IF statements for example to display each individual value however you want. Example as follows.

Code:
[cb:if FIELD_NAME=~"/VALUE_1/"]<div>Value 1</div>[/cb:if] [cb:if FIELD_NAME=~"/VALUE_2/"]<div>Value 2</div>[/cb:if] [cb:if FIELD_NAME=~"/VALUE_3/"]<div>Value 3</div>[/cb:if] [cb:if FIELD_NAME=~"/VALUE_4/"]<div>Value 4</div>[/cb:if] [cb:if FIELD_NAME=~"/VALUE_5/"]<div>Value 5</div>[/cb:if]

Another option is to download and install CB Query Field then use the below query for example to redisplay the selected values however you want.

Code:
SELECT REPLACE( `FIELD_NAME`, '|*|', '</br >' ) FROM `#__comprofiler` WHERE `id` = '[user_id]'

The above is mainly useful if label and value are the same though. If you use the label feature the above will result in the value being output and not the label.

Both usages will avoid double storage. The substitution usage being more complex to setup, but most efficient and more control over the display.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: nant

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum