How can I display the name part of drop down list using K#

Claudette Bentley asked on September 28, 2015 20:43

How can I display the name part of drop down list using K#

I have a drop down list that has a value and name.

Example:

  • Sport1@email.com; Sport1
  • Sport2@email.com; Sport2
  • Sport3@email.com; Sport3

I am using this pull down to select the email address that will receive the email notification. This works fine but I want to be able to display the name part of the pull down value in the email I am generating.

I can display the value, meaning the email address, using

{% SelectSport.Value #%}

But I cannot figure out how to display the name like “Sport1”

Correct Answer

Jim Spillane answered on September 29, 2015 01:13

Hi Claudette.

Here is a way using a delimiter(:) to store both the email and display text in the value...

Sport1@email.com:Sport1;Sport1
Sport2@email.com:Sport2;Sport2
Sport3@email.com:Sport3;Sport3

By using Split() you can get the email and display text respectively...

{% SelectSport.Split(":")[0] |(identity)GlobalAdministrator%}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on September 28, 2015 21:10

Only the value is been stored in database, and the text is only used during display the form. So the simple and quick way maybe to parse out sport1 from the email before @.

0 votesVote for this answer Mark as a Correct answer

Claudette Bentley answered on September 28, 2015 21:24 (last edited on September 28, 2015 21:24)

Hi Rui. Thanks for the advice.

I had written the example as [ Sport1@email.com;Sport1 ] for simplicity but the actual value is more like [ personsemail@email.com;Sport1 ] so I cannot use your suggestion.

Is there any way to pull the Name value of the pull down item while still in the form and post it to a hidden field that can be saved to the table?

0 votesVote for this answer Mark as a Correct answer

Claudette Bentley answered on September 29, 2015 18:24

Thanks Jim Spillane. Worked like a Charm.

0 votesVote for this answer Mark as a Correct answer

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