React multi select not able to select negative value
Hi i am using react multi select with negative and positive values.When i select -1
it is automatically changed to 1. So not able to select -1. other values working fine.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: '1'};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
Please help how to select -1 with react multi select.
Demo
javascript reactjs multi-select
add a comment |
Hi i am using react multi select with negative and positive values.When i select -1
it is automatically changed to 1. So not able to select -1. other values working fine.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: '1'};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
Please help how to select -1 with react multi select.
Demo
javascript reactjs multi-select
add a comment |
Hi i am using react multi select with negative and positive values.When i select -1
it is automatically changed to 1. So not able to select -1. other values working fine.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: '1'};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
Please help how to select -1 with react multi select.
Demo
javascript reactjs multi-select
Hi i am using react multi select with negative and positive values.When i select -1
it is automatically changed to 1. So not able to select -1. other values working fine.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: '1'};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
Please help how to select -1 with react multi select.
Demo
javascript reactjs multi-select
javascript reactjs multi-select
edited Nov 21 '18 at 11:46
ManirajSS
asked Nov 21 '18 at 11:38
ManirajSSManirajSS
1,27541641
1,27541641
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You need to store the values property in state as an array, i.e.:
this.state = {
values:
}
And then, change handleChange to this:
handleChange(event) {
let choices = event.target.selectedOptions;
let final = ;
for(let i=0; i<choices.length; i++) {
final.push(choices[i].value);
}
this.setState({ value: final });
}
And it should work.
Here is a link to a working version:
https://codesandbox.io/s/p3705q0zm
Cheers!
add a comment |
Use array for value if multiple is true based on the documentation.
For multiselect behavior use options as described in this post.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
add a comment |
I noticed that my console was logging the following error
Warning: The
value
prop supplied to must be an array ifmultiple
is true.
I took the liberty of fixing that and coincidentally the -1
selection started working:
class FlavorForm extends React.Component {
constructor (props) {
super(props)
this.state = { values: }
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange (event) {
const values = this.state.values.includes(event.target.value)
? this.state.values
: this.state.values.concat(event.target.value)
this.setState({ values: values })
}
handleSubmit (event) {
alert(`Your favorite flavor is: ${this.state.values}`)
event.preventDefault()
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select
value={this.state.values}
onChange={this.handleChange}
multiple
>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}
add a comment |
Remove value attribute from select element it is invalid there.
<select onChange={this.handleChange} multiple>...</select>
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag usingvalue
attribute on the<select>
element is the preferred way.
– Esa Lindqvist
Nov 21 '18 at 12:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411256%2freact-multi-select-not-able-to-select-negative-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to store the values property in state as an array, i.e.:
this.state = {
values:
}
And then, change handleChange to this:
handleChange(event) {
let choices = event.target.selectedOptions;
let final = ;
for(let i=0; i<choices.length; i++) {
final.push(choices[i].value);
}
this.setState({ value: final });
}
And it should work.
Here is a link to a working version:
https://codesandbox.io/s/p3705q0zm
Cheers!
add a comment |
You need to store the values property in state as an array, i.e.:
this.state = {
values:
}
And then, change handleChange to this:
handleChange(event) {
let choices = event.target.selectedOptions;
let final = ;
for(let i=0; i<choices.length; i++) {
final.push(choices[i].value);
}
this.setState({ value: final });
}
And it should work.
Here is a link to a working version:
https://codesandbox.io/s/p3705q0zm
Cheers!
add a comment |
You need to store the values property in state as an array, i.e.:
this.state = {
values:
}
And then, change handleChange to this:
handleChange(event) {
let choices = event.target.selectedOptions;
let final = ;
for(let i=0; i<choices.length; i++) {
final.push(choices[i].value);
}
this.setState({ value: final });
}
And it should work.
Here is a link to a working version:
https://codesandbox.io/s/p3705q0zm
Cheers!
You need to store the values property in state as an array, i.e.:
this.state = {
values:
}
And then, change handleChange to this:
handleChange(event) {
let choices = event.target.selectedOptions;
let final = ;
for(let i=0; i<choices.length; i++) {
final.push(choices[i].value);
}
this.setState({ value: final });
}
And it should work.
Here is a link to a working version:
https://codesandbox.io/s/p3705q0zm
Cheers!
answered Nov 21 '18 at 12:03
Gabor SzekelyGabor Szekely
3079
3079
add a comment |
add a comment |
Use array for value if multiple is true based on the documentation.
For multiselect behavior use options as described in this post.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
add a comment |
Use array for value if multiple is true based on the documentation.
For multiselect behavior use options as described in this post.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
add a comment |
Use array for value if multiple is true based on the documentation.
For multiselect behavior use options as described in this post.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
Use array for value if multiple is true based on the documentation.
For multiselect behavior use options as described in this post.
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
class FlavorForm extends React.Component {
constructor(props) {
super(props);
this.state = {value: ['1']};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange = ({target}) => {
this.setState(prevState => ({
value: .filter.call(target.options, o => o.selected).map(o => o.value)
}));
}
handleSubmit(event) {
alert('Your favorite flavor is: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select value={this.state.value} onChange={this.handleChange} multiple>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
ReactDOM.render(
<FlavorForm />,
document.getElementById('root')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
edited Nov 22 '18 at 18:46
answered Nov 21 '18 at 12:03
gazdagergogazdagergo
1,400718
1,400718
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
add a comment |
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
But I need multiselect only.Anyhow thanks for your effort!
– ManirajSS
Nov 22 '18 at 8:36
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
I upgraded with multiselect behaviort.
– gazdagergo
Nov 22 '18 at 18:47
add a comment |
I noticed that my console was logging the following error
Warning: The
value
prop supplied to must be an array ifmultiple
is true.
I took the liberty of fixing that and coincidentally the -1
selection started working:
class FlavorForm extends React.Component {
constructor (props) {
super(props)
this.state = { values: }
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange (event) {
const values = this.state.values.includes(event.target.value)
? this.state.values
: this.state.values.concat(event.target.value)
this.setState({ values: values })
}
handleSubmit (event) {
alert(`Your favorite flavor is: ${this.state.values}`)
event.preventDefault()
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select
value={this.state.values}
onChange={this.handleChange}
multiple
>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}
add a comment |
I noticed that my console was logging the following error
Warning: The
value
prop supplied to must be an array ifmultiple
is true.
I took the liberty of fixing that and coincidentally the -1
selection started working:
class FlavorForm extends React.Component {
constructor (props) {
super(props)
this.state = { values: }
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange (event) {
const values = this.state.values.includes(event.target.value)
? this.state.values
: this.state.values.concat(event.target.value)
this.setState({ values: values })
}
handleSubmit (event) {
alert(`Your favorite flavor is: ${this.state.values}`)
event.preventDefault()
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select
value={this.state.values}
onChange={this.handleChange}
multiple
>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}
add a comment |
I noticed that my console was logging the following error
Warning: The
value
prop supplied to must be an array ifmultiple
is true.
I took the liberty of fixing that and coincidentally the -1
selection started working:
class FlavorForm extends React.Component {
constructor (props) {
super(props)
this.state = { values: }
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange (event) {
const values = this.state.values.includes(event.target.value)
? this.state.values
: this.state.values.concat(event.target.value)
this.setState({ values: values })
}
handleSubmit (event) {
alert(`Your favorite flavor is: ${this.state.values}`)
event.preventDefault()
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select
value={this.state.values}
onChange={this.handleChange}
multiple
>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}
I noticed that my console was logging the following error
Warning: The
value
prop supplied to must be an array ifmultiple
is true.
I took the liberty of fixing that and coincidentally the -1
selection started working:
class FlavorForm extends React.Component {
constructor (props) {
super(props)
this.state = { values: }
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange (event) {
const values = this.state.values.includes(event.target.value)
? this.state.values
: this.state.values.concat(event.target.value)
this.setState({ values: values })
}
handleSubmit (event) {
alert(`Your favorite flavor is: ${this.state.values}`)
event.preventDefault()
}
render () {
return (
<form onSubmit={this.handleSubmit}>
<label>
Pick your favorite flavor:
<select
value={this.state.values}
onChange={this.handleChange}
multiple
>
<option value="-1">Grapefruit</option>
<option value="0">Lime</option>
<option value="1">Coconut</option>
<option value="2">Mango</option>
</select>
</label>
<input type="submit" value="Submit" />
</form>
)
}
}
answered Nov 21 '18 at 11:54
Esa LindqvistEsa Lindqvist
12116
12116
add a comment |
add a comment |
Remove value attribute from select element it is invalid there.
<select onChange={this.handleChange} multiple>...</select>
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag usingvalue
attribute on the<select>
element is the preferred way.
– Esa Lindqvist
Nov 21 '18 at 12:03
add a comment |
Remove value attribute from select element it is invalid there.
<select onChange={this.handleChange} multiple>...</select>
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag usingvalue
attribute on the<select>
element is the preferred way.
– Esa Lindqvist
Nov 21 '18 at 12:03
add a comment |
Remove value attribute from select element it is invalid there.
<select onChange={this.handleChange} multiple>...</select>
Remove value attribute from select element it is invalid there.
<select onChange={this.handleChange} multiple>...</select>
answered Nov 21 '18 at 11:58
alowsarwaralowsarwar
328317
328317
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag usingvalue
attribute on the<select>
element is the preferred way.
– Esa Lindqvist
Nov 21 '18 at 12:03
add a comment |
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag usingvalue
attribute on the<select>
element is the preferred way.
– Esa Lindqvist
Nov 21 '18 at 12:03
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag using
value
attribute on the <select>
element is the preferred way.– Esa Lindqvist
Nov 21 '18 at 12:03
According to this stackoverflow.com/questions/21733847/… and this reactjs.org/docs/forms.html#the-select-tag using
value
attribute on the <select>
element is the preferred way.– Esa Lindqvist
Nov 21 '18 at 12:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53411256%2freact-multi-select-not-able-to-select-negative-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown