JavaScript AJAX Functions
From All n One's bxp software Wixi
- New Ajax function - "Populate_AltList"
- New Ajax function - "LiveSearchTable"
- New Ajax function - "InsertCount"
- New Ajax function - "dbInsertRecord"
"Populate_AltList"
This function allows you retrieve two values from another record in a database and using the two values populate both the text and value of drop down list options limited to 200 records
Worked example
aryAjax_Settings[0] = 'client_demo'; //Your system name
aryAjax_Settings[1] = ''; //The CMI API Username
aryAjax_Settings[2] = ''; //The CMI API User password
aryAjax_Settings[3] = '1'; //The campaign which contains the product list
aryAjax_Settings[4] = 'strCDA_1_field_0_0'; //The field which contains the limiting / grouping factor
aryAjax_Settings[5] = document.getElementById('strCDA_2_field_0_59').value; //The value to limit the responses by, in this case only yes items
aryAjax_Settings[13] = -1; //Limit responses -1 do not limit
aryAjax_Settings[14] = 'false'; //Draw a table
aryAjax_Settings[15] = 'divWarning'; //Where to draw error messages if any
aryAjax_Settings[16] = 'Populate_AltList'; //Engine to use i.e. Populate
aryAjax_Settings[6] = 'intCDA_1_Id,strCDA_1_field_0_1'; //The field in the other campaign to be returned order = value, text
aryAjax_Settings[12] = 'id,Name of cust'; //Headings for xml troubleshooting
aryAjax_Settings[17] = 'strCDA_2_field_0_60'; //The field in the current campaign into which the products will be inserted.
aryAjax_Settings[22] = document.getElementById('intSystemGenerated_CompanyId').value; //Auto Login - System
aryAjax_Settings[23] = document.getElementById('intSystemGenerated_UserId').value; //Auto Login - User
aryAjax_Settings[24] = document.getElementById('intSystemGenerated_LoginKey').value; //Auto Login - SessionId
fn_Ajax_BE_Process();
"Populate_AltList"
This function allows you retrieve two values from another record in a database and using the two values populate both the text and value of drop down list options limited to 200 records
Worked example
aryAjax_Settings[0] = 'client_demo';
aryAjax_Settings[1] = '';
aryAjax_Settings[2] = '';
aryAjax_Settings[3] = 1;
aryAjax_Settings[4] = 'strCDA_1_field_0_0';
aryAjax_Settings[5] = document.getElementById('strCDA_2_field_0_59').value;
aryAjax_Settings[13] = '-1'
aryAjax_Settings[14] = 'true';
aryAjax_Settings[15] = 'HospitalListPrivate';
aryAjax_Settings[6] = 'intCDA_1_Id,strCDA_1_field_0_1,strCDA_1_field_0_3,strCDA_1_field_0_6';
aryAjax_Settings[12] = 'Id,Hospital Name,Post Code,AMH';
aryAjax_Settings[16] = 'Table';
aryAjax_Settings[17] = 'intCDA_1_Id,strCDA_1_field_0_1,strCDA_1_field_0_3,strCDA_1_field_0_6';
aryAjax_Settings[22] = document.getElementById('intSystemGenerated_CompanyId').value; //Auto Login - System
aryAjax_Settings[23] = document.getElementById('intSystemGenerated_UserId').value; //Auto Login - User
aryAjax_Settings[24] = document.getElementById('intSystemGenerated_LoginKey').value; //Auto Login - SessionId
aryAjax_Settings[11] = '../inboundsales/userInbound-details.asp?intCampaign_Id=1&ID=';
fn_Ajax_BE_Process();
"InsertCount" This function counts the amount of records in the database chosen that matches the criteria entered
aryAjax_Settings[0] = 'client_demo'; //Your system name
aryAjax_Settings[1] = ''; //The CMI API Username
aryAjax_Settings[2] = ''; //The CMI API User password
aryAjax_Settings[3] = '292'; //The campaign which contains the product list
aryAjax_Settings[4] = 'strCDA_292_field_0_5'; //The field which contains the limiting / grouping factor
aryAjax_Settings[5] = document.getElementById('strCDA_495_field_0_2').value; //The value to limit the responses by, in this case only yes items
aryAjax_Settings[13] = -1; //Limit responses -1 do not limit
aryAjax_Settings[14] = 'false'; //Draw a table
aryAjax_Settings[15] = 'divWarning'; //Where to draw error messages if any
aryAjax_Settings[16] = 'InsertCount'; //Engine to use i.e. Populate
aryAjax_Settings[6] = 'intCDA_X_Id'; //The field to count
aryAjax_Settings[12] = 'id,Name'; //Headings for xml troubleshooting
aryAjax_Settings[17] = 'strCDA_495_field_0_7'; //The field in the current campaign into which the products will be inserted.
aryAjax_Settings[22] = document.getElementById('intSystemGenerated_CompanyId').value; //Auto Login - System
aryAjax_Settings[23] = document.getElementById('intSystemGenerated_UserId').value; //Auto Login - User
aryAjax_Settings[24] = document.getElementById('intSystemGenerated_LoginKey').value; //Auto Login - SessionId
fn_Ajax_BE_Process();
"dbInsertRecord"
This function allows you to transfer a value from one campaign into another. In the following example, the value of strCDA_638_field_0_1 is transferred into strCDA_41_field_0_1.
Worked example
var str_Company_Name = document.getElementById('strCDA_638_field_0_1').value;
if (typeof aryAjax_Settings=='undefined')
alert('Library did not load');
else {
aryAjax_Settings[0] = 'client_allnone'; //the client system
aryAjax_Settings[1] = '';
aryAjax_Settings[2] = '';
aryAjax_Settings[3] = '41'; //the ID of the campaign to transfer the data into
aryAjax_Settings[4] = 'null';
aryAjax_Settings[5] = 'null';
aryAjax_Settings[13] = -1;
aryAjax_Settings[14] = 'false';
aryAjax_Settings[15] = '';
aryAjax_Settings[16] = 'dbInsertRecord'; //the function to use
aryAjax_Settings[6] = 'intCurrentIdOfRecordInserted'; //The fields to be returned into the array
aryAjax_Settings[12] = 'intCDA_41_Id'; //The column names of those fields
aryAjax_Settings[17] = 'strCDA_638_field_0_33'; //The field on the source campaign which will contain the ID of the new inserted
//record after the ajax has executed.
aryAjax_Settings[22] = document.getElementById('intSystemGenerated_CompanyId').value; //ID of the company
aryAjax_Settings[23] = document.getElementById('intSystemGenerated_UserId').value; //The user's ID
aryAjax_Settings[24] = document.getElementById('intSystemGenerated_LoginKey').value; //
aryAjax_Settings[34] = 'strCDA_41_field_0_4'; //Fields to insert to
aryAjax_Settings[35] = str_Company_Name; //Values to insert
aryAjax_Settings[36] = ""; //Field to search on
aryAjax_Settings[37] = ""; //Value to search with
aryAjax_Settings[38] = "False"; //Add a CCl
fn_Ajax_BE_Process();
}