I have a page that contains multiple iframes. All iframes reference the same page. Each iframe page contains a form that I want to submit to the server. There's a "Submit All" button on the page containing the iframes that when clicked calls this function:
function submitAll() {
var fs = d3.selectAll('iframe')[0];
for (var i = 0; i < fs.length; i++) {
try {
var el = fs[i];
var doc = el.contentDocument;
var root = el.contentWindow['root'];
var f = doc.getElementById('submit-form');
removeParentNodeReference(root);
doc.getElementById('POST-name').value = document.getElementById('name').value;
doc.getElementById('POST-email').value = document.getElementById('email').value;
doc.getElementById('POST-phone').value = document.getElementById('phone-number').value;
doc.getElementById('POST-json').value = JSON.stringify(root);
doc.getElementById('POST-submit-info').click();
}
catch (e) {
console.log(e.message);
}
}
The function grabs the content document from each iframe. With the iframe's document, it'll proceed to fill in some form values for the form in the iframe page. The function will then grab the button of the form and click it. This calls off a function in the iframe that does some processing and submits the form.
In chrome, all iframes' forms are submitted. However, in firefox, the form submission will only happen for the first form. I've went into the debugger and see that even though it's looping through for all the iframe pages, only one submission actually happens.
Anyone have any ideas?
Thanks.