Dropdown onChange
See original GitHub issueis there a way to get more than just the value from the onChange event? I’d like to get other values from the objects defined in options.
eg:
` const options = [
{ key: 1, text: 'Green', value: ComponentGroup.GREEN, color: 'green' },
{ key: 2, text: 'Red', value: ComponentGroup.RED, color: 'red'},
{ key: 3, text: 'Blue', value: ComponentGroup.BLUE, color: 'blue'},
]
return (
<Dropdown className={styles.root} options={options} onChange={this.selectGroup} pointing='top left' icon={null} trigger={
<span><span className={styles.groupIcon} style={{ backgroundColor: this.state.groupColor}} />Group</span>
} />
);
}
private readonly selectGroup = (event: React.SyntheticEvent<HTMLDivElement>, data: any) => {
this.props.setGroup(data.value);
this.setState({ groupColor: data.color });
}`
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Dropdown using javascript onchange - Stack Overflow
I have a simple drop down and I want ...
Read more >onchange Event - W3Schools
The onchange event occurs when the value of an element has been changed. ... The other difference is that the onchange event also...
Read more >Get selected value of dropdown in JavaScript/jQuery on change
The idea is to bind the change event handler to the select box using the .change(handler) method. Now an alert is displayed whenever...
Read more >JavaScript dropdown onchange - TAE - Tutorial
It is an event in JavaScript used to make the web pages dynamic. The onchange event gets triggered whenever the value of an...
Read more >Get selected Text and Value of DropDownList in OnChange ...
The HTML Select DropDownList has been assigned a JavaScript OnChange event handler. When an item is selected in the HTML Select DropDownList, the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would propose to keep your values unique. Consider also the reverse case, if there are several duplicate values, which one does the Dropdown select when used as a controlled component? There would be no way to know for sure.
You shouldn’t worry too much about iterating though an array. It’s a fairly simple operation and a standard practice.
If you are keen on avoiding the iteration, you can have
value
store the index for each option.