I am trying to understand an existing piece of software, and have come accross the following:
On the screen there is a button with the text "Apply Now", and From what I understand, the inputtags of the HTML create this button.
I am trying to understand what happens in the code when the button is pressed.
Previously, when I have used forms, action has had a value, for example a page name, so I could work out where the code was going.
In this case, action does not have a value. From searching on the internet, it seems this means the form is being submitted to the same page.
My question is, how can I tell where on the page the code is being submitted to? Or, to put it another way, how can I work out what is going on with the code after the button has been pressed?
Is it the case that the page is reloaded again, and all the data that has been filled out in the form is posted to the page and the page loads with that data already loaded?
Here is the JS method fnPreSubmit and any related methods. It seems to me these validate the form before it posts back to the same page?
function fnPreSubmit()
{
var oFrm = document.forms['AppForm'];
// First set any disable inputs back to enabled so that the value gets sent
for (var ii = 0; ii < arrROC.length; ii++)
{
var oReadOnlyInput = oFrm[arrROC[ii][0]];
if (oReadOnlyInput.disabled)
{
oReadOnlyInput.disabled = false;
}
}
// Sort out the date fields
fnProcessDateFields(oFrm);
dataLayer.push({'event': 'ApplicationSubmit'});
return true;
}
function fnProcessDateFields(pFrm)
{
var sName = "";
if (pFrm['datefield'] != undefined)
{
for (var ii = 0; ii < pFrm['datefield'].length; ii++)
{
sName = pFrm['datefield'][ii].value;
pFrm[sName].value = pFrm['date_dd_' + sName].value + '/' + pFrm['date_mm_' + sName].value + '/' + pFrm['date_yyyy_' + sName].value;
}
}
}