Difference between revisions of "AJAX - Function - Live Search Table"

From All n One's bxp software Wixi

Jump to: navigation, search
Line 1: Line 1:
 +
= Primary Function =
 +
  
 
This AJAX function gives the user the ability to draw a data table with one of two custom buttons that only display when certain criteria are met i.e only allow the user to select a customer where the customers account is set to live.
 
This AJAX function gives the user the ability to draw a data table with one of two custom buttons that only display when certain criteria are met i.e only allow the user to select a customer where the customers account is set to live.
  
<source lang="javascript" collapse="true" first-line="1">
 
  
/*************************************
+
 
Function:
+
= Example uses =
*************************************/
+
 
function fn_PopulatePrivateHospitalTable(){
+
*
+
*
document.getElementById('HospitalListPrivate').innerHTML = '';
+
 
+
 
if (typeof aryAjax_Settings=="undefined")
+
 
alert("Library did not load");
+
= Code =
 +
 
 +
 
 +
<syntaxhighlight lang="javascript">
 +
 
 +
/******************************************************************************************************
 +
Application: This function ............
 +
Version [1.0] Date [2016-08-29] Author [PJ]
 +
******************************************************************************************************/
 +
function fn_FunctionName(){
 +
if (typeof aryAjax_Settings=='undefined') { alert('Library did not load'); }
 
else {
 
else {
 +
// Clear all settings
 +
fn_Ajax_bxp_ResetSettings();
 +
 +
// Security Settings
 +
aryAjax_Settings[0] = 'client_demo';
 +
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[0] = "";                                             //Your system name
+
// Retrieval Settings
aryAjax_Settings[1] = "";                                                             //The CMI API Username
+
aryAjax_Settings[16] = 'LiveSearchTable';                 //Engine to use
aryAjax_Settings[2] = "";                                                             //The CMI API User password
+
aryAjax_Settings[3] = 1; //The form with the data
aryAjax_Settings[3] = "1";                                                             //The Id of the campaign
+
aryAjax_Settings[4] = 'strCDA_1_field_0_0'; //The field to search on
aryAjax_Settings[4] = 'strCDA_1_field_0_0';
+
aryAjax_Settings[5] = document.getElementById('strCDA_2_field_0_0').value; //The value to limit by
aryAjax_Settings[5] = document.getElementById('strCDA_2_field_0_59').value;          
+
aryAjax_Settings[13] = '-1' //Limit response
aryAjax_Settings[13] = "-1";                                                           //Id of the current record, used for delimiting and not repeating current
+
aryAjax_Settings[40] = "500"; //Retrieval limit if applicable
aryAjax_Settings[14] = "true";                                                         //Click through to campaign?
+
aryAjax_Settings[15] = "HospitalListPrivate";                                           //The id of the destination to which the matching links will be inserted
+
//Display management
aryAjax_Settings[16] = "LiveSearchTable";                                             //The types of processing
+
aryAjax_Settings[15] = 'divOutput';              //Where to draw the data or error messages if any
 +
 +
//Common Functional settings
 +
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_1';  //The field in the current campaign into which the products will be inserted.
 +
aryAjax_Settings[28] = ''; //Function to be executed after retrieval
 +
 +
//Function specific settings
 +
aryAjax_Settings[25] = "strCDA_2_field_0_60";                                      //Field to be updated when live option clicked
 +
aryAjax_Settings[29] = "Last"; //Buttons in the first column or the last column
 +
aryAjax_Settings[30] = "Green,Red"; //Green/Red button functionality
 +
aryAjax_Settings[31] = "Select,Not Available"; //Button Text (multi separated by ','  )
 +
aryAjax_Settings[32] = "0"; //value for matching to show button 2
 +
//Execute
 +
fn_Ajax_bxp_Process(); //The main execution of the AJAX
 +
 +
//Write URL out (Comment out after testing)
 +
if (document.getElementById('divURL')){
 +
document.getElementById('divURL').innerHTML = "<a href='" + aryAjax_Settings[7] + "' target='_blank'>Constructed AJAX URL</a>";
 +
}
 +
}
 +
}
 
 
aryAjax_Settings[6] = 'intCDA_1_Id,intCDA_1_Id,strCDA_1_field_0_1,strCDA_1_field_0_3';
+
</syntaxhighlight>
aryAjax_Settings[12] = 'Id,Hospital Name,Post Code,AMH';
+
 
aryAjax_Settings[17] = 'intCDA_1_Id,intCDA_1_Id,strCDA_1_field_0_1,strCDA_1_field_0_3';
+
 
 +
 
 +
= Troubleshooting =
 +
 
 +
 
 +
For any errors messages and troubleshooting AJAX please read here [[AJAX_-_Error_messages_and_troubleshooting]]
 +
 
 +
 
 +
 
 +
= Associated reading =
 +
 
  
//Use my login to allow me to search
+
For all our custom AJAX functions please read here [[AJAX_-_Start_Here]]
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
+
For the full array of all possible parameters please read here [[AJAX_-_Full_Array_of_Parameters]]
  
//LiveSearch fields
 
aryAjax_Settings[25] = "strCDA_2_field_0_60";                                          //Field to be updated when live option clicked
 
 
//Live Search Format Options
 
aryAjax_Settings[29] = "Last"; //Buttons in the first column or the last column
 
aryAjax_Settings[30] = "Green,Red"; //Green/Red button functionality
 
aryAjax_Settings[31] = "Select Hospital,Not Available"; //Button Text (multi separated by ',' 
 
aryAjax_Settings[32] = "0"; //value for matching to show button 2
 
fn_Ajax_BE_Process();
 
    }
 
}
 
  
</source>
+
For how the security engine of AJAX works [[AJAX_-_Security_engine]]
  
  
Under construction [[AJAX_-_Start_Here]]
 
  
  
 
[[Category:Topic:JavaScript]]
 
[[Category:Topic:JavaScript]]
 
[[Category:Topic:AJAX]]
 
[[Category:Topic:AJAX]]

Revision as of 08:25, 31 August 2016

1 Primary Function

This AJAX function gives the user the ability to draw a data table with one of two custom buttons that only display when certain criteria are met i.e only allow the user to select a customer where the customers account is set to live.


2 Example uses


3 Code

/******************************************************************************************************
Application: This function ............
Version [1.0] Date [2016-08-29] Author [PJ]
******************************************************************************************************/
function fn_FunctionName(){
	if (typeof aryAjax_Settings=='undefined') { alert('Library did not load'); }
	else {
		// Clear all settings
		fn_Ajax_bxp_ResetSettings();

		// Security Settings
		aryAjax_Settings[0] 		= 'client_demo';
		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

		// Retrieval Settings
		aryAjax_Settings[16] 		= 'LiveSearchTable';                 									//Engine to use
		aryAjax_Settings[3] 		= 1;																	//The form with the data
		aryAjax_Settings[4] 		= 'strCDA_1_field_0_0'; 												//The field to search on
		aryAjax_Settings[5] 		= document.getElementById('strCDA_2_field_0_0').value; 					//The value to limit by
		aryAjax_Settings[13] 		= '-1'																	//Limit response
		aryAjax_Settings[40] 		= "500";																//Retrieval limit if applicable
		
		//Display management
		aryAjax_Settings[15] 		= 'divOutput';               											//Where to draw the data or error messages if any
		
		//Common Functional settings
		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_1';   												//The field in the current campaign into which the products will be inserted.
		aryAjax_Settings[28] 		= '';																	//Function to be executed after retrieval
		
		//Function specific settings
		aryAjax_Settings[25] 		= "strCDA_2_field_0_60";                                       			//Field to be updated when live option clicked
		aryAjax_Settings[29] 		= "Last";																//Buttons in the first column or the last column 	
		aryAjax_Settings[30] 		= "Green,Red";															//Green/Red button functionality 					
		aryAjax_Settings[31] 		= "Select,Not Available";												//Button Text (multi separated by ','  	)			
		aryAjax_Settings[32] 		= "0";																	//value for matching to show button 2 	
		//Execute
		fn_Ajax_bxp_Process();																				//The main execution of the AJAX
		
		//Write URL out (Comment out after testing)
		if (document.getElementById('divURL')){
			document.getElementById('divURL').innerHTML = "<a href='" + aryAjax_Settings[7] + "' target='_blank'>Constructed AJAX URL</a>";
		}
	}
}


4 Troubleshooting

For any errors messages and troubleshooting AJAX please read here AJAX_-_Error_messages_and_troubleshooting


5 Associated reading

For all our custom AJAX functions please read here AJAX_-_Start_Here


For the full array of all possible parameters please read here AJAX_-_Full_Array_of_Parameters


For how the security engine of AJAX works AJAX_-_Security_engine