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

Associative Array, Drp-DwnList and Accesing "SubArray" Values ?

$
0
0

Based on the users selection on a drop-down box, I need to be able to access different elements associated with that selection (elements of a subArray, so to speak)

 

I am not certain how to go about creating arrays in LiveCycle. I've tried a number of things including:

 

  • putting the array name in the "variables tab" of the Form Properties, with a value of [] -- that doesn't seen to be the way to go, so I removed it
  • using rounded brackets ( instead of square [
  • declaring the arrays differently using var codeDetail = new Array(array,Values,Here);
  • putting the code in a fragment--not sure how to reference the values,

 

I have the following code residing in the "Exit" event for the drop-down box:

 

var codeDetail = [];   //an associative array
codeDetail["99999"] = ["None",null,null,null,null,null,null,null];
codeDetail["78400"] = ["Trampoline",40,45,50,60,10,20,40];
codeDetail["78020"] = ["Horse(s)",10,12,15,20,5,10, 20];
codeDetail["78401"] = ["Horse Boarding (each)",19,23,28,39,17,24,48];
codeDetail["78010"] = ["Watercraft - Outboard over 50 HP (each)",13,18,20,24,17,24,48];
codeDetail["78011"] = ["Watercraft - Inboard or I/O over 50 HP (each)",30,35,40,50,17,24,48];
codeDetail["78050"] = ["Recreational Vehicle: ATV (each)",40,51,61,84,9,11,22];
codeDetail["78053"] = ["Recreational Vehicle: Snowmobiles (each)",36,46,55,76,9,11,22];
codeDetail["78052"] = ["Recreational Vehicle: Golf Carts (each)",29,37,44,61,9,11,22];
codeDetail["73000"] = ["Personal Injury",14,19,22,31,null,null,null];
codeDetail["78030"] = ["Office, School or Studio",10,11,13,19,9,17,34];
codeDetail["78060"] = ["Retail Sales",36,46,56,77,3,4,8];
codeDetail["78061"] = ["Incidental Business Pursuits",36,46,56,77,3,4,8];
codeDetail["78070"] = ["Additional Insured: Premises Only",8,10,12,17,null,null,null];
codeDetail["78090"] = ["Additional Insured - Personal Libility",31,40,50,69,9,17,34];
codeDetail["78040"] = ["Seasonal Residence Occupied by Insured",10,11,13,19,3,4,8];
codeDetail["78041"] = ["Rented to Others: One Family",23,28,34,47,9,17,34];
codeDetail["78042"] = ["Rented to Others: Two Family",29,35,43,61,11,23,45];
codeDetail["78043"] = ["Rented to Others: Three Family",43,55,66,90,17,33,60];
codeDetail["78044"] = ["Rented to Others: Four Family",67,83,100,139,24,50,80];
codeDetail["76000"] = ["Waterbed Liability",10,12,13,19,null,null,null];
codeDetail["78300"] = ["Non-Owned and Hired Auto Liability",56,69,80,92,17,24,48];

 

itemChosen = [];  //a subArray

var i = this.rawValue

itemChosen = [codeDetail[i]];    //  values based on user's selection

 

The goal is to now be able to use the itemChosen values and simply refer to them:

 

this.rawValue = itemChosen[i]   or   this.rawValue = itemChosen[someField.rawValue]

 

So if this drop-down box has a rawValue = "78400" then itemChosen[2] would have a value of 45 (see above).

 

Am I anywhere close?

 

Also, a couple of other questions:

 

When using a variable.value or a field.rawValue as the index value for itemChosen[i]

do you include "" or .value or .rawValue in the index brackets?

 

Do you ever use .value when referencing an array as in: itemChosen[i].value

 

How do I make sure arrays and variables created like this are global, or not? I tried with and without the "var" declaration

 

Thanks much!

 

Stephen


Viewing all articles
Browse latest Browse all 16286

Trending Articles



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