# coding logic - React/Redux - grab inputs from multiple radio button menus using one submit button

**URL:** https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876
**Category:** programming
**Created:** [October 31, 2018, 9:45pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876 "2018-10-31T21:45:53Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [October 31, 2018, 9:45pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/1 "2018-10-31T21:45:53Z")

</div>

hello, do you think it’s a useful idea to create a generator to sequentially cycle through the four radio button groups filtering for each dimension (room size, room shape, pet?, kids?) one at a time upon clicking the single Submit button? Is this an intelligent way of thinking how to collect and filter results?

new to this forum. I’m not even sure this is the place to ask these kinds of questions. I wanted to add a screen shot of the radio button cards but couldn’t figure out how. I tried to drag and drop the image into this field but that didn’t work.

-George

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [October 31, 2018, 9:50pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/2 "2018-10-31T21:50:02Z")

</div>

Do you mean generator as in iterator? Like `function* myGenerator...`? For what you’re describing, it doesn’t seem necessary. Hard to know without more information, but creating a generator doesn’t seem necessary for basic iteration like that.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [October 31, 2018, 9:54pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/3 "2018-10-31T21:54:06Z")

</div>

ok, thanks…maybe the ES6/JS Generator function is overkill

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [October 31, 2018, 9:58pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/4 "2018-10-31T21:58:39Z")

</div>

BTW, welcome to the forum 😃

And this was a fine place to ask. We don’t seem too terribly strict on organization here, though I will often move things myself if they’re out of place. I wouldn’t worry about it too much. 😉

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [October 31, 2018, 10:46pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/5 "2018-10-31T22:46:57Z")

</div>

thank you! I appreciate it. My next problem is going to be a checkbox problem. It’s tricky because one of my checkboxes has 12 items and a user can check 1, or none, or all, or any combination possible…the problem is, there is over 400 million possible ways of checking 12 boxes and I will have take the user’s selection and match it to the “closest” possible match.

btw, can I post screen shots here?

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [November 1, 2018, 4:05am UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/6 "2018-11-01T04:05:03Z")

</div>

You should be able to copy and paste images. There is an upload image button as well, so that is definitely possible 🙂

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 1, 2018, 1:35pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/7 "2018-11-01T13:35:22Z")

</div>

testing

 ![utility](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/3/3f50be41e57f2c1442511a7604d66f7cadef8bc5.jpeg)

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 1, 2018, 1:55pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/8 "2018-11-01T13:55:30Z")

</div>

so yeah, I’m wondering what the best coding logic for this is -\> The user selects a room type from the pictures (I didn’t label the pics yet)… the left-most pic is bedrooms. The user selects bedrooms and all bedrooms load into state as an array of objects ( state = [{}, {}, {}…]; ) from the backend (Firebase). The user fills out the radio button forms and hits submit button and I want to return images of bedrooms which match the user’s radio button selection. My original thought was to use a JS Generator function to filter each radio button card sequentially to avoid coming up with some wonky conditional logic statement like some sort of nested ternary statements. I’ve only been coding about 4 months so these types of problems are still a little challenging for me. any suggestions?

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [November 1, 2018, 2:55pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/9 "2018-11-01T14:55:43Z")

</div>

Is all the data in firebase? Is there more happening than just pick an option, query firebase, get more options?

And are you intent on using generators? You seem like you’re all about generators 😉 I’m sure we can cram them into whatever you’re doing, but for someone only 4 months in, complications like generators are usually steered clear of.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 3, 2018, 5:06pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/10 "2018-11-03T17:06:46Z")

</div>

yeah re firebase. there’s gonna be user subscription/acct info, room-design-attribute info…etc. And yeah, there’s more problems to come. The radio boxes in this room-design “Utility” section are just straight-up filters. But there’s two more sections of user input “Functional” and “Style”… these are all checkboxes. Because a user can check boxes in so many different combinations (like millions!) I don’t look at that as a filter problem – I look at that as a matching algorithm problem. For that I was thinking of setting up a bipartite matrix which reflects the presence and absence of room attributes and using a python script and maximum bipartite matching to match the checkbox input to the “nearest” or “closest” (think Hopcroft Karp algo and Hamming distance) room designs.

haha, but I don’t know yet how to add a Python script to an app stack. I’m assuming/hoping that won’t be too hard to figure out. : /

back to the generator function --\>

Also yeah, I’m a little obsessive … and l like to use cool things 🙂 and I _do_ reach for things that are above my coding experience level 🤓. But, all seriousness aside , I was thinking to use the JS Generators because I want one filter to resolve and return results before I filter the next group of radio buttons. I thought a JS Generator would be a nice way of “throttling” and sequencing the filtering process.

more info --\>

I am working on a prototype of a interior design app for some friends of mine. I’ve taken a bunch of online learning courses and I wanted to build a React/Redux mockup of their site to get better at coding before I circle back around and deal with prototyping my own app Impending Bloom which will be a social impact investing platform. Impending Bloom is a much more complicated app … well, just because for one, it’s an investing platform but also because I want to build a quant-driven visual investing environment using D3. So I have to dig more into D3 pretty soon also.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 3, 2018, 5:24pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/11 "2018-11-03T17:24:39Z")

</div>

also fyi (“for yoozguys info”) I hopped into this forum rather than doing Stack Exchange and Overflow becuz I started looking at yoozguys backgrounds and I was like whooaaa…this is like a little micro-cosmos of folks that probably know wtf they are doing.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 4, 2018, 1:44am UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/12 "2018-11-04T01:44:28Z")

</div>

here are the rest of the “Style” and “Function” radio button and checkbox cards →

 ![style](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/4/43512cc7bac45aebaa6fbc6d31145440caca0e8e.png)

so my thought was to “wrap” this whole sequence of filtering and matching processes in a generator function(s) to have greater control over the sequence in which info is gathered, computed (I mean any computation that needs to be done … esp in the case of the checkboxes), and returned.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 4, 2018, 1:45am UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/13 "2018-11-04T01:45:05Z")

</div>

![functional](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/4/4abe2c2d40d6302c47f7a7f5d5e6b57d40c974b1.png)

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 4, 2018, 3:18am UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/14 "2018-11-04T03:18:03Z")

</div>

I guess what I’m thinking, or what I’m attracted to, is the concept that JavaScript Generators allow us to set up a controlled iteration over different types of data structures. I kind of feel like the generator gives me an over-arching tool with which I can parse and then re-gather up the different filters and matching algorithms in any configuration or grouping that provides the most useful result - matching room designs to users’ needs, style and tastes.

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [November 5, 2018, 2:17pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/15 "2018-11-05T14:17:55Z")

</div>

I see a lot more info has been thrown at this but I’m not sure I’m understanding much more 😉 . Going back:

> [@glassbeads](#):
>
> My original thought was to use a JS Generator function to filter each radio button card sequentially to avoid coming up with some wonky conditional logic statement like some sort of nested ternary statements.

Here, I can see if you are revealing radio button cards individually over time as users make selections, that a generator could help provide you with what’s next. But I’m not sure I’m seeing where additional logic would be needed. Would the next card be dependent on the selections of the prior? The examples you’ve provided don’t seem to show that kind of relation. Also I’m still not sure a generator is necessarily needed here or would instead feel forced. It would come down to the specifics of the implementation.

You should be able to run your python script on the server easily enough, though how depends on your backend and assuming you have enough control in that backend and have the permissions to pull that off. In Node, for example, you can run a python script through [spawn](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).

> [@glassbeads](#):
>
> I guess what I’m thinking, or what I’m attracted to, is the concept that JavaScript Generators allow us to set up a controlled iteration over different types of data structures.

You’re on point here. This is what generators are good at. But often they can also complicate this task. Again, I think it comes down to the specifics. For me, I generally avoid generators because they tend to overcomplicate things. Where they become useful is value iteration for custom objects, though even then it’s often easier and more useful to simply return that data as an array.

---

<div class="post-metadata">

### Author: ![glassbeads](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glassbeads/32/9342_2.png) [@glassbeads](https://forum.kirupa.com/u/glassbeads)
#### Post date: [November 5, 2018, 8:24pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/16 "2018-11-05T20:24:49Z")

</div>

Thank you!!! I appreciate the feedback. ur rt, I am kinda obsessive but also since I’m a newb I think I tend to wanna reach for what I think are cool things. I _have_ to admit that. Most of all I have to be honest with myself. Now, with that said, I gonna build it anyhow 👨‍🔧 OR, at least I think I’m gonna build it. I hope it’s not out of my reach.

anyhow, I wanna give this a shot. I have to learn. I will post again when I have some code together and then PLEASE tell me if you think it makes sense _or,_ if like you’ve been warning, I’m unnecessarily complicating things.

a couple additional things though - the output of one set of radio buttons/checkboxes is dependent on previous selections (buttons/boxes) …_and_ with the checkboxes I foresee having to outsource the matching algo to another script in which case I think I’m gonna want control over the whole sequence of when outputs from those scripts are returned before moving on to the next filter/algo.

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [November 5, 2018, 8:28pm UTC](https://forum.kirupa.com/t/coding-logic-react-redux-grab-inputs-from-multiple-radio-button-menus-using-one-submit-button/638876/17 "2018-11-05T20:28:23Z")

</div>

> [@glassbeads](#):
>
> anyhow, I wanna give this a shot. I have to learn.

Yes. Do this. 😃 I don’t want to dissuade you from _using_ them, though I do want to provide you with any information that you could use to tell whether or not you _need_ them (or at least they’d be worthy of use). The more you use them the more you can see what they offer and how they work. Learn by doing :proud:
