Topic: Rails 3.2 option chooser in form

He,im new to Rails and i have a big problem with an option chooser. The user can choose per checkbox, if he wants to use a selectbox or a text_field. The jquerycode does his job by showing or hidding the div. But when i submit the form, :task_name gets always the value of the task_new div but never the one of the task_use. What im doing wrong?Is there a way for hidding/showing the div per railsfunction?
Maybe i set up some tmp variables and give :task_name the value?! How can this be done?

I tryed the trick with the tmp_variables. The get an value but now i stuck, how to set the value of the tmp_variable to :task_name ....
<% :task_name = @tmp_variable%> doest work????

Heres the code:
Create new Task :
<input type="checkbox" value="false" name="check" id="check" checked="false" />

<div class="task_use" id="task_use" style="display:block;">
<%= f.fields_for :task do |t|%> 
<%= :task_name, Task.all.collect {|n|[n.task_name]}%>
<div class="task_new" id="task_new" style="display:none;">
<%= f.fields_for :task do |t|%>
<%= t.label :task_name %><br />
<%= t.text_field :task_name %>
<div class="actions">
<%= f.submit %>
<% end %>

$(document).ready(function() {
$("#check").change(function () {
if ($('#check').checked == false) {
} else {

Thx for your support

Last edited by mwiron (2012-09-14 02:08:49)