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.

Grabbing the selected value from a label/value list?

See original GitHub issue

So if I instantiate with a list like this:

awesomplete.list = [ [ "Belarus", "BY" ], [ "China", "CN" ], [ "United States", "US" ] ];

Then I’ll end up with the value in my user’s input. I’m trying to have the label appear in the input upon selection, but also be able to know what value matches their choice, so I can stick that in a hidden input.

So for the above, if the user chose “China”, I’d like “China” to show up in their choice, but have “CN” get stashed in a variable/hidden input field.

Is Replace the right method for doing this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zampagecommented, Jul 3, 2017

just instantiate the list like this: awesomplete.list = [ {label: "Belarus", value: "BY"}, {label: "China", value: "CN"}, {label; "United States", value: "US"} ];

If you want to do something upon selection (eg. write value/label to a hidden field) check the event awesomplete-selectcomplete and use the event.text.value / event.text.label variables.

1reaction
LeaVeroucommented, Mar 8, 2019

I can create a PR but unsure if it will be merged given the backlog?

PRs are not merged FIFO. Easy, small, uncontested PRs are merged ahead of any backlog.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to grab label value from checked option with jQuery
Im trying to grab value from label checkbox:checked. I have created this function var levels = $('input[name=form[radio1]]:checked + label') ...
Read more >
How i can get the label of the selected value in Combobox
I'm developing a LWC Combobox and I want to get the label of the selected value in the handleChange() method, not the id...
Read more >
Selected value not showing in the input field [Controlled ...
It set's the value from an onChange correctly, and the props update and console.log properly, but the component doesn't visually show the new ......
Read more >
How does ARAS manipulate the values in a dropdown list ...
To provide some context about why I'm asking, I'm grabbing the user's selected value from the dropdown list via javascript and then doing ......
Read more >
Solved: Change the value of a label based on a selected va...
Solved: Hi, I have sharepoint list T012. And two columns MineName and MineID. In power app I have a dropdown with the values...
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