# Random Picker Coding Help

**URL:** <https://forum.code.org/t/random-picker-coding-help/35370>\
**Category:** Coding and Debugging Help\
**Created:** [November 5, 2021, 6:52pm UTC](https://forum.code.org/t/random-picker-coding-help/35370 "2021-11-05T18:52:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctaylor](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/ctaylor/32/6865_2.png) [@ctaylor](https://forum.code.org/u/ctaylor)\
**Post date:** [November 5, 2021, 6:52pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/1 "2021-11-05T18:52:11Z")

</div>

I am trying to help a group of students to write code to randomly select one user input from two options. Is this possible? App project link below.

**Link to the project or level:** [[Code.org - App Lab](https://studio.code.org/projects/applab/EMv_gTABpQJrvxEqCGGc5IhCPvwN2HjIXR8mhSvIXzc)  
**What I expect to happen:** Students want one user input to be randomly selected

---

<div class="post-metadata">

**Author:** ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)\
**Post date:** [November 5, 2021, 8:00pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/2 "2021-11-05T20:00:26Z")

</div>

Hi @ctaylor,

Yes. You can! I’ll walk you through the pseudocode as I see it and I hope that will help you see the solution.

- Because this is somewhat of a contained set of actions, I would create a separate function.
- Next, I would create a variable that generates a random number based on how many choices there are.
- If one of the numbers is chosen, you would then set the property of the desired text box with the text from the text box the users entered their choices into.
- The other box is set to the other option.
- Make sure you call the function in the event that should trigger the random number generation.

That’s how I see it:) I hope it helps. I believe this is a post for CSP - for the Decision Maker project. I will move the post there to CSP if you have follow-up questions.

~Michelle

---

<div class="post-metadata">

**Author:** ![ctaylor](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/ctaylor/32/6865_2.png) [@ctaylor](https://forum.code.org/u/ctaylor)\
**Post date:** [November 5, 2021, 9:55pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/3 "2021-11-05T21:55:00Z")

</div>

Thank you! I teach using a modified CSD. I will check out the other course.

---

<div class="post-metadata">

**Author:** ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)\
**Post date:** [November 5, 2021, 11:39pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/4 "2021-11-05T23:39:20Z")

</div>

Oh…I see. Let us know if you have covered those concepts (functions, random number, conditionals). If not, we can support you with more detail.

---

<div class="post-metadata">

**Author:** ![ctaylor](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/ctaylor/32/6865_2.png) [@ctaylor](https://forum.code.org/u/ctaylor)\
**Post date:** [November 7, 2021, 7:54pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/6 "2021-11-07T19:54:53Z")

</div>

I understand some of this and created code to hide and show a checkmark next to the user input. I think isn’t correct though, because it keeps showing the same checkmark.

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [November 8, 2021, 2:45pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/7 "2021-11-08T14:45:27Z")

</div>

@ctaylor,

From what I can tell, it appears to be working now, so you may have figured it out. The only thing I can see is that if you continually press go without pressing clear in between, it can appear as if both options are checked, but otherwise, I think you have it figured out!

Nice!

Mike

---

<div class="post-metadata">

**Author:** ![ctaylor](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/ctaylor/32/6865_2.png) [@ctaylor](https://forum.code.org/u/ctaylor)\
**Post date:** [November 8, 2021, 7:30pm UTC](https://forum.code.org/t/random-picker-coding-help/35370/8 "2021-11-08T19:30:03Z")

</div>

I did finally figure it out! Thanks!
