Question

I am inserting an Infusionsoft webform into a website I am building for a client. He wants an Infusionsoft webform used which is okay. However The onsubmit of the form has a lot of code that I don't understand. What is its purpose?

Here is the code:

onsubmit="var form = document.forms[0];
var resolution = document.createElement('input');
resolution.setAttribute('id', 'screenResolution');
resolution.setAttribute('type', 'hidden');
resolution.setAttribute('name', 'screenResolution');
var resolutionString = screen.width + 'x' + screen.height;
resolution.setAttribute('value', resolutionString);
form.appendChild(resolution);
var pluginString = '';
if (window.ActiveXObject) {
var activeXNames = {'AcroPDF.PDF':'Adobe Reader',
    'ShockwaveFlash.ShockwaveFlash':'Flash',
    'QuickTime.QuickTime':'Quick Time',
    'SWCtl':'Shockwave',
    'WMPLayer.OCX':'Windows Media Player',
    'AgControl.AgControl':'Silverlight'};
var plugin = null;
for (var activeKey in activeXNames) {
    try {
        plugin = null;
        plugin = new ActiveXObject(activeKey);
    } catch (e) {
        // do nothing, the plugin is not installed
    }
    pluginString += activeXNames[activeKey] + ',';
}
var realPlayerNames = ['rmockx.RealPlayer G2 Control',
    'rmocx.RealPlayer G2 Control.1',
    'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',
    'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',
    'RealPlayer'];
for (var index = 0; index < realPlayerNames.length; index++) {
    try {
        plugin = new ActiveXObject(realPlayerNames[index]);
    } catch (e) {
        continue;
    }
    if (plugin) {
        break;
    }
}
if (plugin) {
    pluginString += 'RealPlayer,';
}
} else {
for (var i = 0; i < navigator.plugins.length; i++) {
    pluginString += navigator.plugins[i].name + ',';
}
}
pluginString = pluginString.substring(0, pluginString.lastIndexOf(','));
var plugins = document.createElement('input');
plugins.setAttribute('id', 'pluginList');
plugins.setAttribute('type', 'hidden');
plugins.setAttribute('name', 'pluginList');
plugins.setAttribute('value', pluginString);
form.appendChild(plugins);
var java = navigator.javaEnabled();
var javaEnabled = document.createElement('input');
javaEnabled.setAttribute('id', 'javaEnabled');
javaEnabled.setAttribute('type', 'hidden');
javaEnabled.setAttribute('name', 'javaEnabled');
javaEnabled.setAttribute('value', java);
form.appendChild(javaEnabled);"

I am wanting to cute out all unnecessary code while keeping the form working.

What does the necessary code do? I have not used Infusionsoft Forms before.

Was it helpful?

Solution

None of that code is needed for the infusionsoft form to actually work and submit. It looks like the person who wrote that code is doing lots of other things that do not have anything to do with infusionsoft.

You could technically delete all of it any the form would work just fine. Here is a sample form so you can see what an infusionsoft webform looks like:

<form accept-charset="UTF-8" action="https://appname.infusionsoft.com/app/form/process/2f7236cb361ea9a84669eb9446ed7d6b" class="infusion-form" method="POST">
    <input name="inf_form_xid" type="hidden" value="2f7236cb361ea9a84669eb9446ed7d6b" />
    <input name="inf_form_name" type="hidden" value="Name of Form" />
    <input name="infusionsoft_version" type="hidden" value="1.29.6.32" />
    <div class="infusion-field">
        <label for="inf_field_FirstName">First Name *</label>
        <input class="infusion-field-input-container" id="inf_field_FirstName" name="inf_field_FirstName" type="text" />
    </div>
    <div class="infusion-field">
        <label for="inf_field_LastName">Last Name *</label>
        <input class="infusion-field-input-container" id="inf_field_LastName" name="inf_field_LastName" type="text" />
    </div>
    <div class="infusion-field">
        <label for="inf_field_Email">Email *</label>
        <input class="infusion-field-input-container" id="inf_field_Email" name="inf_field_Email" type="text" />
    </div>
    <div class="infusion-field">
        <span class="infusion-option">
            <input id="inf_option_Signmeupforthenewsletter" name="inf_option_Signmeupforthenewsletter" type="checkbox" value="455" />
            <label for="inf_option_Signmeupforthenewsletter">Sign me up for the newsletter</label>
        </span>
    </div>
    <div class="infusion-submit">
        <input type="submit" value="Submit" />
    </div>
</form>

I do not suggest you delete the other code however. It is just unrelated to the infusionsoft form itself and its ability to submit.

OTHER TIPS

no I cant see anything to shorten this and it is running a java program for the login fourm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top