Jump to content

Adding a $ in front of field in a array


bkurzbuch

Recommended Posts

I have the code for 2 arrays and need some help with the proper syntax for adding "$" in front of each field. I know what I need to do, but have tried several variations with a syntax error every time. A point in the right direction would be greatly apprecatied. Thank You

var OptionHeaderArray = ["Individual "+Field("Pay Period"), "Two-Party "+Field("Pay Period"), "Family "+Field("Pay Period")];
var UAArray = [Field("UA Individual"), Field("UATwo-Party"), Field("UA Family")];
var UAPlusArray = [Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family")];
var OptionHeaderFilledArray=[];
var UAFilledArray=[];
var UAPlusFilledArray = [];

Link to comment
Share on other sites

I have the code for 2 arrays and need some help with the proper syntax for adding "$" in front of each field. I know what I need to do, but have tried several variations with a syntax error every time. A point in the right direction would be greatly apprecatied. Thank You

var OptionHeaderArray = ["Individual "+Field("Pay Period"), "Two-Party "+Field("Pay Period"), "Family "+Field("Pay Period")];
var UAArray = [Field("UA Individual"), Field("UATwo-Party"), Field("UA Family")];
var UAPlusArray = [Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family")];
var OptionHeaderFilledArray=[];
var UAFilledArray=[];
var UAPlusFilledArray = [];

 

Actually, you have 6 arrays. Each of your variables is assigned to an array. Let's take, for example, the array you've assigned to the 'UAArray' variable. If you want to put a dollar sign in front of the value of each of those fields you could just physically prepend it like this:

var UAArray = [
 [color="Red"]'$' + [/color]Field("UA Individual"), 
 [color="Red"]'$' + [/color]Field("UATwo-Party"), 
 [color="Red"]'$' + [/color]Field("UA Family")
];

 

Or you could use the map method:

var UAArray = [
 Field("UA Individual"), 
 Field("UATwo-Party"), 
 Field("UA Family")
][color="Red"].map(function(element){ return '$' + element; });[/color]

Edited by step
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...