1

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.

Harry
  • 87,580
  • 25
  • 202
  • 214
L84
  • 45,514
  • 58
  • 177
  • 257
  • Judging by the title and question, I felt that the tag had a typo and have re-tagged it to JavaScript. Please feel free to roll it back if it wasn't a typo. – Harry Oct 11 '13 at 03:58
  • Seems like you're using HTML styled code of the infusionsoft form. Do use UNSTYLED code and then you'll less code and you're good to go as well. – Shobhit Mar 29 '18 at 09:03

2 Answers2

2

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.

joshmmo
  • 1,062
  • 2
  • 13
  • 28
  • All of the code on the page is mine but the webform. I am going to try the form with and without the code. Will see what happens. Thanks for the help and posting an example form! – L84 Oct 11 '13 at 07:24
0

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

mjz19910
  • 244
  • 1
  • 13
  • But what login form? This is for a person to submit a query to my client. Is it necessary? – L84 Oct 11 '13 at 03:05
  • 1
    It doesn't look all that crucial...just detects screen size, installed plugins, and various enablements. But who knows. Maybe they have code that deletes the site if RealPlayer isn't installed in the user's browser or something. We'd have to see their code to know for sure. – cHao Oct 11 '13 at 03:09