# How to get selected option in dropdown menu?

**URL:** <https://www.ruby-forum.com/t/how-to-get-selected-option-in-dropdown-menu/259478>\
**Category:** Uncategorized\
**Created:** [May 5, 2020, 6:07am UTC](https://www.ruby-forum.com/t/how-to-get-selected-option-in-dropdown-menu/259478 "2020-05-05T06:07:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghjgjh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/13edae/32.png) [@ghjgjh](https://www.ruby-forum.com/u/ghjgjh)\
**Post date:** [May 5, 2020, 6:07am UTC](https://www.ruby-forum.com/t/how-to-get-selected-option-in-dropdown-menu/259478/1 "2020-05-05T06:07:16Z")

</div>

I was wondering how to get the selected option in dropdown menu.

 \<% @quiz.codes.each do |code| %\> \<%= simple\_format code.code %\> \<%= simple\_format code.notes %\> \<%= form\_with(model: [code, code.student\_answers.build], local: true) do |form| %\> 

```
								<%= form.select(:correct_answer_ids, code.correct_answers.pluck(:variable, :variable), {prompt: 'Choose variable'}, class: 'answer-variable')%>
								<%= form.select(:correct_answer_ids, code.correct_answers.pluck(:role, :role), {prompt: 'Choose role'}, class: 'answer-role')%>
							</p>
							<% end %>
						</td>
					</tr>
				<% end %>
			</tbody>
```
