javascript - Collect data into variable in rails form -


i writing rails application in have form add student information. form has text fields name, age, address etc. when press submit button, info submitted server , can create new student when page refreshes.

i not want this. want when submit button pressed, hold these data in variable(or other means) , can continue adding next student info. can continue multiple times. after adding n students, press finish button , data of n students should submitted server. possible?

i adding example here...  a.first name , last name dynamically add  n number of address details , phone number  b.have separate table name, address , phone. c.one many relation d name can have number of address , phone.(have name id foreign key in address , phone table)  ex: first name = tom, last name = jerry, address:xx1, phone:yy1,address:xx2, phone:yy2.  store  first name = tom, last name = jerry, address:xx1, phone:yy1 first name = tom, last name = jerry, address:xx2, phone:yy2    sample erb file      <%= form_tag(controller: "contacts", action: "create", method: "post", )  %>       <blockquote>     <%= label_tag :first_name %>     <%= text_field_tag :first_name, params[:first_name] %>      <%= label_tag :last_name %>     <%= text_field_tag :last_name, params[:last_name] %>     </blockquote>        <blockquote>     <h3>adress details </h3>     <div id="skillset1">       <%= render 'address' %>     </div>     <a href="javascript:;" id="addnewtag1">add additional address details</a>      <div class="hide" id="new_skills_form1">       <%= render partial: "address", locals: {skill: false} %>     </div>       </blockquote>      <blockquote>     <h3>phone number </h3>     <div id="skillset">       <%= render 'phone' %>     </div>     <a href="javascript:;" id="addnewtag">add additional phone details</a>      <div class="hide" id="new_skills_form">       <%= render partial: "phone", locals: {skill: false} %>     </div>      </blockquote>     <div class="actions"><%= submit_tag 'save' %></div>     <div><%= link_to 'back', :action => :index %></div> <% end %>  javascript      $(document).ready(function(){     $("#addnewtag").click(function(){         $("#skillset").append($("#new_skills_form").html());     }); });  $(document).ready(function(){     $("#addnewtag1").click(function(){         $("#skillset1").append($("#new_skills_form1").html());     }); }); 

Comments