I`m looking to create a form where upon submission, all the values from the form are added up together.
At the same time I would define a session within the controller so later the added up values can be written into the DB.
views/quiz/new.html.erb :
<% form_tag do %>
<%= form_tag(:controller => "quiz", :action => "new", :method => "post") %>
<div id="container">
<p class="question">The glass is...</p>
<ul>
<%= radio_button_tag :value, '2' %>
<li>Half full.</li><br>
<%= radio_button_tag :value, '1' %>
<li>Half empty.</li><br>
<%= radio_button_tag :value, '3' %>
<li>What glass?</li><br>
</ul>
<p class="question">When does the narwhal bacon?</p>
<ul>
<%= radio_button_tag :value, '2' %>
<li>Tomorrow.</li><br>
<%= radio_button_tag :value, '1' %>
<li>Midnight.</li><br>
<%= radio_button_tag :value, '3' %>
<li>Mmm, I love bacon.</li><br>
</ul>
<p class="right">
<%= submit_tag "Submit Answers", :class => "submit_button" %>
</p>
</div>
<% end %>
Don`t quite know how the controller would look like for this though.
How would I add the selected values together upon submission?
1 Answer