question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selecting id's, displaying values

See original GitHub issue

I’ve just implemented typeahead to serve as a kind of autocomplete select tag, fetching the names, companies and emails of a bunch of users. However upon selecting one of them, it sets the value of the text field to the id of the object in question, while I want to display the name.

In other words, I’d like to mimic something like <option value="1">John Doe</option> where I would submit the 1 value while never having to display it. And I prefer not having to do an additional query to find a person based on their name (which may not even be unique all the time).

I hope that makes sense. Hannes

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
steswinbankcommented, Apr 12, 2013

You can use the custom events ‘typeahead:selected’ and ‘typeahead:autocompleted’ to populate a hidden input within the form. These custom events contain the datum selected as an argument. You’ll want something like: $(#TypeAheadInput").on(“typeahead:selected typeahead:autocompleted”, function(e,datum) { $(hiddenInput).val() = datum.id; })

4reactions
cromuluscommented, May 13, 2016

agreed. I’d really like to be able to specify what values are submitted in the typeahead for independent of the values displayed…

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML select dropdownlist how to display the VALUE/ID ...
I like how the first select element displays the original value when a different option is selected. Very nice :) – slee423. Jun...
Read more >
ID selectors - CSS: Cascading Style Sheets - MDN Web Docs
The CSS ID selector matches an element based on the value of the element's id attribute. In order for the element to be...
Read more >
HTML select id Attribute - Dofactory
The id attribute on a select element assigns a unique identifier to that element. ... Clicking the button displays the selected value of...
Read more >
Solved: Problem with selecting dropdown values(IDs) from N...
I am storing Y Table ID in X Table. In PowerApps Edit screen I am going to show one drop down for Y...
Read more >
How To Select HTML Elements Using ID, Class, and Attribute ...
You will begin by creating an HTML and a CSS file that you will edit throughout the tutorial. You will then add id...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found