I have a 3 forms on different web pages, each with a submit button. Clicking submit on an individual page, opens up an AJAX call to process_form
function of unknown origin (see function below), which loads the form for you. Essentially, upon clicking Submit, the function assembles form values, into a request and loads up a sub-page via an AJAX request.
Each form of the 3 is the same at its core, but has slight variations and options.
What I want to do is to merge the 3 forms into a single one, and then have my clicking Submit open up 3 new browser tabs, one for each specific form option.
So I am looking for a way to reuse this process_form
function (desirable), to open up the windows, or maybe modify it (undesirable as its being used by lots of other files) to accomplish my goal.
See snippet below to see how it works on my end. An answer I am seeking is to have a single form that opens up the 3 original forms, but each being in a new tab window.
//abridged version of the library function I use for AJAX
function process_form(form, url, redir, response, method, delay) {
var formObj = document.getElementById(form);
var post_str = "";
if (method == "POST") {
for (var i = 0; i < formObj.length; i++) {
if (formObj.elements[i].tagName == "INPUT") {
if (formObj.elements[i].type == "text") {
post_str += escape(formObj.elements[i].name) + "=" + encodeURIComponent(formObj.elements[i].value) + "&";
}
}
}
}
//here this will be a load_page() call
//but replaced here with alert to show functionality
alert("Load Form with [" + post_str + "]");
}
<form id="a">
<input name="opt_a" type="text" value='4' />
<input type="button" onclick="process_form('a', '', '', '', 'POST', '')" value="SelectA" id="selButton" name="selButton" />
</form>
<form id="b">
<input name="opt_b" type="text" value='5' />
<input type="button" onclick="process_form('b', '', '', '', 'POST', '')" value="SelectB" id="selButton" name="selButton" />
</form>
<form id="c">
<input name="opt_c" type="text" value='6' />
<input type="button" onclick="process_form('c', '', '', '', 'POST', '')" value="SelectC" id="selButton" name="selButton" />
</form>
Merged Form will look something like this (unfinished)
<form id="a_b_c">
<input name="opt_a" type="text" value='4' />
<input name="opt_b" type="text" value='5' />
<input name="opt_c" type="text" value='6' />
<!-- submit functionality opening up separate tabs is what I seek -->
</form>