Quantcast
Channel: Adobe Community : Popular Discussions - LiveCycle Designer
Viewing all articles
Browse latest Browse all 16286

How do I set global variables for use by ALL form1.#subform[0] items?

$
0
0

Hi All,

 

I know how to code javascript but am new to Adobe LiveCycle.  When I open script editor, I have the following code (all code is inun-bolded):

 

----- form1.#subform[0]::initialize: - (FormCalc, client) ------------------------------------------

//////////////////////////////
// BEGIN: SET GLOBAL PRICES //
//////////////////////////////

var Cityscope_Sydney_CostUser1 = 60.39;
var Cityscope_Sydney_CostUsers2to5 = 3.02;
var Cityscope_Sydney_CostUsers6to20 = 1.21;
var Cityscope_Sydney_CostHardCopyWithOnline = 14.59;
var Cityscope_Sydney_CostHardCopyWithoutOnline = 54.67;
var Cityscope_Sydney_CostHardCopyAdditional = 14.59;

var Cityscope_NorthSydney_CostUser1 = 48.40;
var Cityscope_NorthSydney_CostUsers2to5 = 2.42;
var Cityscope_NorthSydney_CostUsers6to20 = 0.97;
var Cityscope_NorthSydney_CostHardCopyWithOnline = 14.59;
var Cityscope_NorthSydney_CostHardCopyWithoutOnline = 43.54;
var Cityscope_NorthSydney_CostHardCopyAdditional = 14.59;


////////////////////////////
// END: SET GLOBAL PRICES //
////////////////////////////

----- form1.#subform[0]::enter: - (FormCalc, client) -----------------------------------------------

 

----- form1.#subform[0]::exit: - (FormCalc, client) ------------------------------------------------

 

----- form1.#subform[0]::calculate: - (FormCalc, client) -------------------------------------------

 

----- form1.#subform[0]::validate: - (FormCalc, client) --------------------------------------------

 

----- form1.#subform[0]::preSave - (FormCalc, client) ----------------------------------------------

 

 

 

 

<<======= etc etc etc =======>>

 

 

 

 

----- form1.#subform[0].Item1Cost::initialize: - (JavaScript, client) ------------------------------

 

----- form1.#subform[0].Item1Cost::enter: - (FormCalc, client) -------------------------------------

 

----- form1.#subform[0].Item1Cost::exit: - (FormCalc, client) --------------------------------------

 

----- form1.#subform[0].Item1Cost::calculate: - (JavaScript, client) -------------------------------

//Store form values in user-friendly names.
var AreaSelected = Item1Area.rawValue;
var NumberOfUsersSelected = Item1Users.rawValue;

//Declare other vars.
var Users1Calculation;
var Users2to5Calculation;
var Users6to20Calculation;


//Calculate individual User Cost "components" based on number of users selected for the area.
switch(true)
{
case (NumberOfUsersSelected < 2):
  Users1Calculation = NumberOfUsersSelected * Cityscope_Sydney_CostUser1;
  Users2to5Calculation = 0.00;
  Users6to20Calculation = 0.00;
  break;
case (NumberOfUsersSelected > 1 && NumberOfUsersSelected < 6):
  Users1Calculation = Cityscope_Sydney_CostUser1;
  Users2to5Calculation = (NumberOfUsersSelected - 1) * Cityscope_Sydney_CostUsers2to5;
  Users6to20Calculation = 0.00;
  break;
case (NumberOfUsersSelected > 5):
  Users1Calculation = Cityscope_Sydney_CostUser1;
  Users2to5Calculation = 4 * Cityscope_Sydney_CostUsers2to5;
  Users6to20Calculation = (NumberOfUsersSelected - 5) * Cityscope_Sydney_CostUsers6to20;
  break;
default:
  alert("BROKEN: Calculate individual User Cost components based on number of users selected for the area.");
}

//apply total cost for this item
Item1Cost.rawValue = Users1Calculation + Users2to5Calculation + Users6to20Calculation;

----- form1.#subform[0].Item1Cost::validate: - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Cost::mouseEnter: - (FormCalc, client) --------------------------------

 

----- form1.#subform[0].Item1Cost::mouseExit: - (FormCalc, client) ---------------------------------

 

----- form1.#subform[0].Item1Cost::change: - (FormCalc, client) ------------------------------------

 

----- form1.#subform[0].Item1Cost::full: - (FormCalc, client) --------------------------------------

 

----- form1.#subform[0].Item1Cost::mouseUp: - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Cost::mouseDown: - (FormCalc, client) ---------------------------------

 

----- form1.#subform[0].Item1Cost::click: - (FormCalc, client) -------------------------------------

 

----- form1.#subform[0].Item1Cost::preSave - (FormCalc, client) ------------------------------------

 

----- form1.#subform[0].Item1Cost::postSave - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Cost::prePrint - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Cost::postPrint - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Cost::preSubmit:form - (FormCalc, client) -----------------------------

 

----- form1.#subform[0].Item1Cost::docReady - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Cost::docClose - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Cost::ready:form - (FormCalc, client) ---------------------------------

 

----- form1.#subform[0].Item1Cost::ready:layout - (FormCalc, client) -------------------------------

 

----- form1.#subform[0].Item1Users::initialize: - (FormCalc, client) -------------------------------

 

----- form1.#subform[0].Item1Users::enter: - (FormCalc, client) ------------------------------------

 

----- form1.#subform[0].Item1Users::exit: - (FormCalc, client) -------------------------------------

 

----- form1.#subform[0].Item1Users::calculate: - (FormCalc, client) --------------------------------

 

----- form1.#subform[0].Item1Users::validate: - (FormCalc, client) ---------------------------------

 

----- form1.#subform[0].Item1Users::mouseEnter: - (FormCalc, client) -------------------------------

 

----- form1.#subform[0].Item1Users::mouseExit: - (FormCalc, client) --------------------------------

 

----- form1.#subform[0].Item1Users::change: - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Users::full: - (FormCalc, client) -------------------------------------

 

----- form1.#subform[0].Item1Users::mouseUp: - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Users::mouseDown: - (FormCalc, client) --------------------------------

 

----- form1.#subform[0].Item1Users::click: - (FormCalc, client) ------------------------------------

 

----- form1.#subform[0].Item1Users::preSave - (FormCalc, client) -----------------------------------

 

----- form1.#subform[0].Item1Users::postSave - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Users::prePrint - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Users::postPrint - (FormCalc, client) ---------------------------------

 

----- form1.#subform[0].Item1Users::preSubmit:form - (FormCalc, client) ----------------------------

 

----- form1.#subform[0].Item1Users::docReady - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Users::docClose - (FormCalc, client) ----------------------------------

 

----- form1.#subform[0].Item1Users::ready:form - (FormCalc, client) --------------------------------

 

----- form1.#subform[0].Item1Users::ready:layout - (FormCalc, client) ------------------------------

 

 

...and so on and so forth....

 

 

In short, I want the code within:

----- form1.#subform[0].Item1Cost::calculate: - (JavaScript, client) -------------------------------

 

...to be able to access the variables I have created in:

----- form1.#subform[0]::initialize: - (FormCalc, client) ------------------------------------------


(I have assumed that this is where I would store Global variables)

 

At this stage, the global variables cannot be accessed with the configuration above.  The only was I can get this to work is to cut and paste the global vairables into each form1.#subform[0] item, which of course defeats the purpose of global variables!  I plan to have many more items so would not want to duplicate the global variables for all of them!

 

Can somebody show me how to do this?

 

Any help is very much appreciated!

 

 

Thanks

 

Stanbridge

 

Message was edited by: stanbridgej - colors and or fonts won't save.  Have bolded my question to make code (non-bolded) easier to read (I hope).


Viewing all articles
Browse latest Browse all 16286

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>