Need help on how to convert Jquery .change() to React.js to show/hide divsUse jQuery to hide a DIV when the user clicks outside of itjQuery .load preventing .hide and .show from working?hide image and show iframe but in one div with multiple classjQuery: hide and show an input elementHaving issues showing/hiding div on “onclick” event in select in chromeHow to show/hide DIV on selection of ANY drop-down value?How to show or hide tr with jQuery?Hide/show dynamic generated div based on select optionjQuery hide() Randomly Showing Last DivHow get value datapicker in react toobox custom?
What does the multimeter dial do internally?
Delete elements less than the last largest element
With a data transfer of 50 GB estimated 5 hours, are USB-C claimed speeds inaccurate or to blame?
How to understand flavors and when to use combination of them?
Is it okay to use open source code to do an interview task?
What are the effects of abstaining from eating a certain flavor?
Chilling water in copper vessel
Would denouncing cheaters from an exam make me less likely to receive penalties?
Category-theoretic treatment of diffs, patches and merging?
Can one block with a protection from color creature?
Where are the Wazirs?
How to evaluate the performance of open source solver?
Was it ever illegal to name a pig "Napoleon" in France?
As a supervisor, what feedback would you expect from a PhD who quits?
Why do people prefer metropolitan areas, considering monsters and villains?
Other Space Shuttle O-ring failures
How does one acquire an undead eyeball encased in a gem?
Separate a column into its components based on another table
Four ships at the ocean with the same distance
Is there a method for differentiating informative comments from commented out code?
How do ballistic trajectories work in a ring world?
How do you correct inclination at launch to ISS?
What does "spinning upon the shoals" mean?
Can the word "desk" be used as a verb?
Need help on how to convert Jquery .change() to React.js to show/hide divs
Use jQuery to hide a DIV when the user clicks outside of itjQuery .load preventing .hide and .show from working?hide image and show iframe but in one div with multiple classjQuery: hide and show an input elementHaving issues showing/hiding div on “onclick” event in select in chromeHow to show/hide DIV on selection of ANY drop-down value?How to show or hide tr with jQuery?Hide/show dynamic generated div based on select optionjQuery hide() Randomly Showing Last DivHow get value datapicker in react toobox custom?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a multi select field that shows/hide various based on what is selected.
The values of the are equal to their respective class.
Need help converting the below Jquery code to react to show/hide appropriate s
*****The HTML*****
<select id="my_fields" name="my_fields" multiple="multiple">
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas hide">show/hide gas</div>
<div class="car_wash hide">show/hide car_wash</div>
<div class="parking hide">show/hide parking</div>
<div class="other hide">show/hide other</div>
*****The JQuery*****
$( "#my_fields" ).change(function ()
$( "#my_fields option:selected" ).each(function()
$( "."+ $(this).val() ).show();
);
$( "#my_fields option:not(:selected)" ).each(function()
$( "."+ $(this).val() ).hide();
);
);
*****The React*****
.....imports and class.....
constructor(props)
super(props);
this.state =
value: "",
show:false,
;
this.handleChange = this.handleChange.bind(this);
handleChange(event)
this.setState(
value: event.target.value,
show: true
)
render() {
var show =
display: this.state.show ? "block" : "none"
;
return (
<select
name="my_fields"
multiple
value=this.state.value
onChange=this.handleChange
>
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas" style= show >show/hide gas</div>
<div class="car_wash" style= show >show/hide car_wash</div>
<div class="parking" style= show >show/hide parking</div>
<div class="other" style= show >show/hide other</div>
)
reactjs hide onchange show
add a comment |
I have a multi select field that shows/hide various based on what is selected.
The values of the are equal to their respective class.
Need help converting the below Jquery code to react to show/hide appropriate s
*****The HTML*****
<select id="my_fields" name="my_fields" multiple="multiple">
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas hide">show/hide gas</div>
<div class="car_wash hide">show/hide car_wash</div>
<div class="parking hide">show/hide parking</div>
<div class="other hide">show/hide other</div>
*****The JQuery*****
$( "#my_fields" ).change(function ()
$( "#my_fields option:selected" ).each(function()
$( "."+ $(this).val() ).show();
);
$( "#my_fields option:not(:selected)" ).each(function()
$( "."+ $(this).val() ).hide();
);
);
*****The React*****
.....imports and class.....
constructor(props)
super(props);
this.state =
value: "",
show:false,
;
this.handleChange = this.handleChange.bind(this);
handleChange(event)
this.setState(
value: event.target.value,
show: true
)
render() {
var show =
display: this.state.show ? "block" : "none"
;
return (
<select
name="my_fields"
multiple
value=this.state.value
onChange=this.handleChange
>
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas" style= show >show/hide gas</div>
<div class="car_wash" style= show >show/hide car_wash</div>
<div class="parking" style= show >show/hide parking</div>
<div class="other" style= show >show/hide other</div>
)
reactjs hide onchange show
1
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53
add a comment |
I have a multi select field that shows/hide various based on what is selected.
The values of the are equal to their respective class.
Need help converting the below Jquery code to react to show/hide appropriate s
*****The HTML*****
<select id="my_fields" name="my_fields" multiple="multiple">
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas hide">show/hide gas</div>
<div class="car_wash hide">show/hide car_wash</div>
<div class="parking hide">show/hide parking</div>
<div class="other hide">show/hide other</div>
*****The JQuery*****
$( "#my_fields" ).change(function ()
$( "#my_fields option:selected" ).each(function()
$( "."+ $(this).val() ).show();
);
$( "#my_fields option:not(:selected)" ).each(function()
$( "."+ $(this).val() ).hide();
);
);
*****The React*****
.....imports and class.....
constructor(props)
super(props);
this.state =
value: "",
show:false,
;
this.handleChange = this.handleChange.bind(this);
handleChange(event)
this.setState(
value: event.target.value,
show: true
)
render() {
var show =
display: this.state.show ? "block" : "none"
;
return (
<select
name="my_fields"
multiple
value=this.state.value
onChange=this.handleChange
>
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas" style= show >show/hide gas</div>
<div class="car_wash" style= show >show/hide car_wash</div>
<div class="parking" style= show >show/hide parking</div>
<div class="other" style= show >show/hide other</div>
)
reactjs hide onchange show
I have a multi select field that shows/hide various based on what is selected.
The values of the are equal to their respective class.
Need help converting the below Jquery code to react to show/hide appropriate s
*****The HTML*****
<select id="my_fields" name="my_fields" multiple="multiple">
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas hide">show/hide gas</div>
<div class="car_wash hide">show/hide car_wash</div>
<div class="parking hide">show/hide parking</div>
<div class="other hide">show/hide other</div>
*****The JQuery*****
$( "#my_fields" ).change(function ()
$( "#my_fields option:selected" ).each(function()
$( "."+ $(this).val() ).show();
);
$( "#my_fields option:not(:selected)" ).each(function()
$( "."+ $(this).val() ).hide();
);
);
*****The React*****
.....imports and class.....
constructor(props)
super(props);
this.state =
value: "",
show:false,
;
this.handleChange = this.handleChange.bind(this);
handleChange(event)
this.setState(
value: event.target.value,
show: true
)
render() {
var show =
display: this.state.show ? "block" : "none"
;
return (
<select
name="my_fields"
multiple
value=this.state.value
onChange=this.handleChange
>
<option value="gas">Gas</option>
<option value="car_wash">Car Wash</option>
<option value="parking">Parking</option>
<option value="other">Other</option>
</select>
<div class="gas" style= show >show/hide gas</div>
<div class="car_wash" style= show >show/hide car_wash</div>
<div class="parking" style= show >show/hide parking</div>
<div class="other" style= show >show/hide other</div>
)
reactjs hide onchange show
reactjs hide onchange show
edited Mar 25 at 23:51
Moose
asked Mar 25 at 22:20
MooseMoose
11 bronze badge
11 bronze badge
1
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53
add a comment |
1
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53
1
1
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53
add a comment |
2 Answers
2
active
oldest
votes
Try if this works with some modifications -
state =
values: []
;
handleChange = event =>
const options = Array.from(event.target.options);
const selectedOptions = options.filter(op => op.selected);
const selectedValues = selectedOptions.map(op => op.value);
this.setState( values: selectedValues );
with changes to your return
JSX
...
this.state.values.includes('gas') && <div class="gas">show/hide gas</div>
this.state.values.includes('car_wash') && <div class="car_wash">show/hide car_wash</div>
this.state.values.includes('parking') && <div class="parking">show/hide parking</div>
this.state.values.includes('other') && <div class="other">show/hide other</div>
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
add a comment |
handleChange(event)
var options = event.target.selectedOptions;
var value = [];
for (var i = 0, l = options.length; i < l; i++)
if (options[i].selected)
value.push(options[i].value);
this.setState(
expenseCategory:[].slice.call(event.target.selectedOptions).map(o =>
return o.value;
)
);
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%2f55347240%2fneed-help-on-how-to-convert-jquery-change-to-react-js-to-show-hide-divs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try if this works with some modifications -
state =
values: []
;
handleChange = event =>
const options = Array.from(event.target.options);
const selectedOptions = options.filter(op => op.selected);
const selectedValues = selectedOptions.map(op => op.value);
this.setState( values: selectedValues );
with changes to your return
JSX
...
this.state.values.includes('gas') && <div class="gas">show/hide gas</div>
this.state.values.includes('car_wash') && <div class="car_wash">show/hide car_wash</div>
this.state.values.includes('parking') && <div class="parking">show/hide parking</div>
this.state.values.includes('other') && <div class="other">show/hide other</div>
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
add a comment |
Try if this works with some modifications -
state =
values: []
;
handleChange = event =>
const options = Array.from(event.target.options);
const selectedOptions = options.filter(op => op.selected);
const selectedValues = selectedOptions.map(op => op.value);
this.setState( values: selectedValues );
with changes to your return
JSX
...
this.state.values.includes('gas') && <div class="gas">show/hide gas</div>
this.state.values.includes('car_wash') && <div class="car_wash">show/hide car_wash</div>
this.state.values.includes('parking') && <div class="parking">show/hide parking</div>
this.state.values.includes('other') && <div class="other">show/hide other</div>
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
add a comment |
Try if this works with some modifications -
state =
values: []
;
handleChange = event =>
const options = Array.from(event.target.options);
const selectedOptions = options.filter(op => op.selected);
const selectedValues = selectedOptions.map(op => op.value);
this.setState( values: selectedValues );
with changes to your return
JSX
...
this.state.values.includes('gas') && <div class="gas">show/hide gas</div>
this.state.values.includes('car_wash') && <div class="car_wash">show/hide car_wash</div>
this.state.values.includes('parking') && <div class="parking">show/hide parking</div>
this.state.values.includes('other') && <div class="other">show/hide other</div>
Try if this works with some modifications -
state =
values: []
;
handleChange = event =>
const options = Array.from(event.target.options);
const selectedOptions = options.filter(op => op.selected);
const selectedValues = selectedOptions.map(op => op.value);
this.setState( values: selectedValues );
with changes to your return
JSX
...
this.state.values.includes('gas') && <div class="gas">show/hide gas</div>
this.state.values.includes('car_wash') && <div class="car_wash">show/hide car_wash</div>
this.state.values.includes('parking') && <div class="parking">show/hide parking</div>
this.state.values.includes('other') && <div class="other">show/hide other</div>
edited Mar 27 at 18:43
answered Mar 26 at 1:35
Prithviraj SahuPrithviraj Sahu
2065 bronze badges
2065 bronze badges
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
add a comment |
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
Thank you Prithviraj. What you have provided only work if one option is selected. I need to show each div based on the multiple option selected.
– Moose
Mar 26 at 21:18
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
I have updated the answer. Check it.
– Prithviraj Sahu
Mar 27 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
Yes, that works. I ended with something similar (in answer below) , but your is less code. I was also missing the ".includes" in the conditional
– Moose
Mar 29 at 18:45
add a comment |
handleChange(event)
var options = event.target.selectedOptions;
var value = [];
for (var i = 0, l = options.length; i < l; i++)
if (options[i].selected)
value.push(options[i].value);
this.setState(
expenseCategory:[].slice.call(event.target.selectedOptions).map(o =>
return o.value;
)
);
add a comment |
handleChange(event)
var options = event.target.selectedOptions;
var value = [];
for (var i = 0, l = options.length; i < l; i++)
if (options[i].selected)
value.push(options[i].value);
this.setState(
expenseCategory:[].slice.call(event.target.selectedOptions).map(o =>
return o.value;
)
);
add a comment |
handleChange(event)
var options = event.target.selectedOptions;
var value = [];
for (var i = 0, l = options.length; i < l; i++)
if (options[i].selected)
value.push(options[i].value);
this.setState(
expenseCategory:[].slice.call(event.target.selectedOptions).map(o =>
return o.value;
)
);
handleChange(event)
var options = event.target.selectedOptions;
var value = [];
for (var i = 0, l = options.length; i < l; i++)
if (options[i].selected)
value.push(options[i].value);
this.setState(
expenseCategory:[].slice.call(event.target.selectedOptions).map(o =>
return o.value;
)
);
answered Mar 29 at 18:50
MooseMoose
11 bronze badge
11 bronze badge
add a comment |
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%2f55347240%2fneed-help-on-how-to-convert-jquery-change-to-react-js-to-show-hide-divs%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
1
What have you tried so far? Any react code to show to start?
– Jeremy D
Mar 25 at 23:31
Thanks for looking, Jeremy. React posted above. Essentially, handleChange will show all the <div>s which is a start, but I only want the to show <div>'s that have the same class as the value(s) selected in the select input. When option is not selected, then div should be hidden.
– Moose
Mar 25 at 23:56
Not sure I fully understand the question. Is the idea that if you select gas and car_wash the div gas and car_wash should be shown? If so, you need to keep track of the currenly selected values in your state and toggle the show variable based on whether or not an option is selected. It looks like your state is wrong, and your change handler should check event.target.options and iterate over it to figure out which options are selected.
– Jeremy D
Mar 26 at 21:50
yes, exactly! and if I decide to un-select the option, the div hides. all div's are initially hidden. -- Trying re-create the .each()function in the Jquery code above, but in react.js
– Moose
Mar 26 at 21:53