I have some tabs, each containing their own form and their own submit button. I want to fire off all the forms and send requests for each form at the click of one button. That one button should essentially click each individual submit button for each form (in this case that button would be the button with class “submit_all”. The html:
div class="tab-content" id="tab_content_one"
div id="#tab1" class="tab-pane fade in active"
= form_tag({ action: "route1" }, method: method)
.form-group
textarea.form-control name="words"
input.btn.btn-primary type="submit" class="submit"
div id="tab2" class="tab-pane fade"
= form_tag({ action: "route1" }, method: method)
.form-group
textarea.form-control name="words"
input.btn.btn-primary type="submit" class="submit"
div id="tab3" class="tab-pane fade"
= form_tag({ action: "route1" }, method: method)
.form-group
textarea.form-control name="words"
input.btn.btn-primary type="submit" class="submit"
input.btn.btn-primary type="submit" class="submit_all" onclick="goBack()"
I tried using javascript to retrieve all the submit buttons for each of the forms and iterating through and clicking each submit button however that did not work. It ended up only firing off the final form.
function goBack() {
var submit2 = document.getElementsByClassName('submit')
console.log(submit2)
for (i=0; i<=(submit2.length); i++){
submit2[i].click()
}
Am I doing something wrong? and how else can I go about this?