i am adding and removing fields successfully on click to add_fields and remove_fields. But now i want to add fields N times at once depending on the value of drop down in the parent form. How to do it any idea? here is my parent form
= f.select :total_section, (0..10),{}, :onchange => "generate_form(this.value)"
.field
= f.fields_for :score_sheet_sections do |s|
%div.fields
= render 'score_sheet_section_fields', :f => s
%div.fields
= link_to_add_fields "Add Score Sheet Sections", f, :score_sheet_sections
In my generate form function i only have this:
function generate_form(number) {
for (i = 1; i <= number; i++) {
console.log(i);
}
}
i want to select number of sections(say N or store it in N) and then add score_sheet_sections N times