Call-back syntax

<< Click to Display Table of Contents >>

Navigation:  General Functions > Configuring the MIE (Programmer's Guide) > Portal Design > Request Portal Design (Programmer's Guide) > Ajax Call-backs >

Call-back syntax

The Request Portal has a javascript routine available called DoCallBack.  The DoCallBack routine takes two parameters, the action code and a delimited list of div's to be updated with HTML that will be returned by the MIE.  The following call-backs are available on the Request Portal:

 
A - refresh a control.  This is usually done to refresh a control that is related to another control on the screen, such that when the first control's value changes, it will change the associated list of items in the second control.  Note that you must first set the value of the DOM variable ControlToRefresh553 with the name of the control you want to refresh.  Also note that the control you want to refresh must be contained within a div, and that div must be named the same as the control to refresh with the letters "div" preceding the name.

Example:

(the call-back syntax)
OnChange="SetControlValue('SRPMfr1550','-Select-');SetControlValue('SRPProdDesc1550','-Select-');SetControlValue('ControlToRefresh553','SRPMfr1550');DoCallBack('A','divSRPMfr1550');"

(the actual control inside its div on the form, with a merge tag that defines the control itself)
<div id="divSRPMfr1550" name="divSRPMfr1550">[%SRPMfr1550,Input,,%]</div>

 
C - commit the transaction.  Until this call-back is invoked, all data entered is maintained in the user's DOM (in the browser).  This call-back actually commits the data to the MIE's database and will, if successful, return an order number.  The order number is available via [%V6%] of the predefined variables.  It is also carried in the Order553 DOM variable and can be referenced there. When calling this call-back, all screen areas will be refreshed, so the second variable passed to DoCallBack needs to be the delimited list of all areas (see the example below).

Example:

onclick=if(Validate()==false){return;}NextBack('UP');DoCallBack('C','ButtonArea~HeaderArea~Area1~Area2~Area3~Area4');

 
L - Perform a lookup based on the information contained in the DOM variable ControlToRefresh553.  The variable ControToRefresh is loaded with a comma delimited list of which lookup areas are to be re-generated (1 through 4).  Each lookup area is expected to be contained in the HTML document in a div named divLookup<n><m>, where <n> is the step and <m> is the lookup area within the step (1-4).  The call-back can refresh up to all 4 lookup areas in one call-back, if needed.  Only the lookup areas specified for the current step will be regenerated and returned.

If the lookup area does not specify a DOM variable whose contents are to be used as the key value for performing the lookup, then the javascript that sets up the lookup must first populate the DOM variable KeyValueLU553 with the key value that will be used to perform the lookup.

Example:

onBlur=SetControlValue('KeyValueLU553',this.value);SetControlValue('ControlToRefresh553','1');DoCallBack('L','divLookup11');

 
Q - Return the question and answer section for the currently selected shopping cart item.  Prior to performing this callback, the DOM variable SCidx553 must be set with the index value of the Shopping Cart item for which the Q&A is to be returned.  The Shopping Cart index starts at 1.
 

Example:

onclick=SetControlValue('SCidx553',GetControlValue('SRPItemsInCart550'));DoCallBack('Q','divQA1');

 

NOTE:  Answers to questions are collected and stored in a single DOM variable for each Shopping Cart item.  The specific variable is QA<n>, where n is the index into the current Shopping Cart (starting at 1).  Prior to performing the Q callback, the current collection of answers must be gathered and stored in the respective QA<n> DOM variable - otherwise the answers will be lost and replaced by the return from the MIE.  The Request Portal provides a built-in javascript function called CollectQandA(iReqCatNo) in order to perform this function.  The parameter required by CollectQandA is the ReqCatNo (request catalog item number) of the currently selected request catalog item.  An example of code used to gather current answers before moving away and/or replacing the current Q&A section is as follows:

SetControlValue('QA'+GetControlValue('SCidx553'),CollectQandA(GetControlValueH('ReqCatNo'+GetControlValue('SCidx553'))));SetControlValue('HQA'+GetControlValue('SCidx553'),CollectQandA(GetControlValueH('ReqCatNo'+GetControlValue('SCidx553'))));

 

Note that both the primary DOM variable (QA<n>) is being updated as well as its shadow DOM variable (HQA<n>).  It is very important to also update the shadow DOM variable in order to ensure values are properly carried between callbacks.

 

 
U - Add an item to the shopping cart.  The shopping cart area is returned.  The Request Portal provides a javascript routine called AddManifestItem which is used to perform the call-back.  AddManifestItem takes one parameter, which is the delimited list of divs to be refreshed with the information returned by the call-back.
 

Example:

onclick=AddManifestItem('divOrderArea3');

 

V - Remove any checked line items and refresh the  current step's Shopping Cart area.  This will cause the Shopping Cart area to be re-evaluated, expanded through any tags, and returned as HTML.

Example:

<span class="BlackLink" onclick="DoCallBack('V','divOrderArea3');">Update</span>