# Is there a more elegant way to use an input field that only needs part of the selection to be returned?

**URL:** <https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173>\
**Category:** Have a question?\
**Created:** [April 28, 2025, 12:01am UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173 "2025-04-28T00:01:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RyanSodziak](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/ryansodziak/32/208_2.png) [@RyanSodziak](https://community.textexpander.com/u/RyanSodziak)\
**Post date:** [April 28, 2025, 12:01am UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/1 "2025-04-28T00:01:12Z")

</div>

Is there a more elegant way to use an input field that only needs part of the selection to be returned? Sorry if terminology is wrong.

I want to be able to select from a list of account numbers to insert into spreadsheets/emails. But I need to reference the description associated with that number.

I currently use an optional field to show the descriptions for reference and then a Pop-Up Menu field with the account numbers that I can reference against. Screenshot below.

Is there a better way to do this?

 ![Screenshot 2025-04-28 095946](https://us1.discourse-cdn.com/textexpander/original/1X/f9a6733cf39fffc0fb3ceb8d31dd211f7493f1a0.png)

---

<div class="post-metadata">

**Author:** ![josh.centers](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/josh.centers/32/8_2.png) [@josh.centers](https://community.textexpander.com/u/josh.centers)\
**Post date:** [April 28, 2025, 3:44pm UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/2 "2025-04-28T15:44:17Z")

</div>

Hi Ryan, as I’m understanding it, you want to expand only the account number, but you need to be able to see the account name. Here are a couple of solutions to try. I’ve created concept Snippets for you in the [Community Snippets Public Group](https://snippets.textexpander.com/group/fa796ecbe167aeb836aced0a65e43b94). You can copy those to one of your own groups and customize it to your needs.

## With Optional Sections

You can try this out by expanding `com.accts`.

 ![Screenshot 2025-04-28 at 10.36.23 AM](https://us1.discourse-cdn.com/textexpander/original/1X/966fa503590d63f3c99cfdc18c8bf25af6641c60.png)

With this solution, we use optional sections for each account. We use the account name for the name of the optional section, but it only expands the account number.

 ![Screenshot 2025-04-28 at 10.36.57 AM](https://us1.discourse-cdn.com/textexpander/original/1X/678b7ef7991ce1ad36042a9ea58fd4868791773e.png)

## With JavaScript

You can try this by expanding `com.jsnums`. It’s not the prettiest solution, but it offers a dropdown list with the descriptions. Select an account, click OK, and it will expand only the account number.

 ![Screenshot 2025-04-28 at 10.38.46 AM](https://us1.discourse-cdn.com/textexpander/original/1X/00f12f1551c5ffd7db4a186b90eca861e5431404.png)

You don’t need to know how the code works to customize this Snippet. You can simply customize the `account` Popup Menu by double-clicking it.

 ![Screenshot 2025-04-28 at 10.41.05 AM](https://us1.discourse-cdn.com/textexpander/original/1X/69ed02df03dd1dbaf787c6c89afb421bd04394ac.png)

 ![Screenshot 2025-04-28 at 10.41.45 AM](https://us1.discourse-cdn.com/textexpander/original/1X/f2daf6a06c73250750463b22600d0dbe353670f8.png)

## Bonus Option: Regular Text Snippets

If the menu isn’t necessary, you could simply create Snippets for each account number. So `;checking` would expand into 12345 and `;savings` would expand into 67890.

---

<div class="post-metadata">

**Author:** ![HaniSarji](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/hanisarji/32/225_2.png) [@HaniSarji](https://community.textexpander.com/u/HaniSarji)\
**Post date:** [April 29, 2025, 1:25am UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/3 "2025-04-29T01:25:42Z")

</div>

In the JavaScript snippet below, you need to modify the key-value pairs in the code and the Popup Menu, but the result is elegant:

 ![IMG_1950](https://us1.discourse-cdn.com/textexpander/original/1X/88479ba6e64d95dd45fc4d6ece0008a32761bc79.jpeg)  
 ![IMG_1951](https://us1.discourse-cdn.com/textexpander/original/1X/64ec3b201d268d8ca701ebc37fd5083490e30106.jpeg)  
 ![IMG_1948](https://us1.discourse-cdn.com/textexpander/original/1X/c653c416b809bc3874e336efdf032b8225443d59.jpeg)  
 ![IMG_1949](https://us1.discourse-cdn.com/textexpander/original/1X/11acc63d4665472608e5d983fc3c4e5ee04692ec.jpeg)

In iOS, you would add this code to a JavaScript snippet:

```JavaScript
// Define the bank accounts directly
let accountNumber = {
  "Checking Account": "12345",
  "Savings Account": "67890",
  "Investment Account": "11223"
};

let account = "%fillpopup:name=Select the account:default=Checking Account:Savings Account:Investment Account%";

accountNumber[account];

%filltop%

```

---

<div class="post-metadata">

**Author:** ![RyanSodziak](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/ryansodziak/32/208_2.png) [@RyanSodziak](https://community.textexpander.com/u/RyanSodziak)\
**Post date:** [April 29, 2025, 5:01am UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/4 "2025-04-29T05:01:35Z")

</div>

Thanks Josh. This is fantastic and really appreciate the explanation. I have subscribed to the group and found the snippet in there to play with.

I knew there would be a better way. I can see me using this in a number of different snippets now.

---

<div class="post-metadata">

**Author:** ![josh.centers](https://sea3.discourse-cdn.com/textexpander/user_avatar/community.textexpander.com/josh.centers/32/8_2.png) [@josh.centers](https://community.textexpander.com/u/josh.centers)\
**Post date:** [April 29, 2025, 1:59pm UTC](https://community.textexpander.com/t/is-there-a-more-elegant-way-to-use-an-input-field-that-only-needs-part-of-the-selection-to-be-returned/173/5 "2025-04-29T13:59:04Z")

</div>

Very cool, I realized I could add `%filltop%` to the `com.jsnums` Snippet to make it look cleaner:

 ![Screenshot 2025-04-29 at 8.51.38 AM](https://us1.discourse-cdn.com/textexpander/original/1X/5430ed2a1c49c76f24b39fd03b1d809b45209702.png)

Lots of options in this topic! In this case, you can create a JavaScript object with a key-value pair like @HaniSarji or you can insert a native TextExpander Popup Menu.

> [@RyanSodziak](#):
>
> Thanks Josh. This is fantastic and really appreciate the explanation. I have subscribed to the group and found the snippet in there to play with.

Glad we could help!
