View Full Version : Need Help w/Structure & formatting

12-29-2003, 09:53 AM
1) How does one creat an array of structures in JS? I cannot find any examples of structure e.g
type custinfo {
Name string
Phone string
ID long

arraynew(60) of custinfo

2) How can I format an output field to be currency w/o having to write a routine

12-29-2003, 02:53 PM
What you'll need to look into is object literals. They've got a funky syntax, but they work slick as anything:

var myObj = {
property : 'value',
method : function () {
(function definition)
calculatedValue : (formula)

Then, to create a myObj, you just need a loop:

var objArray = new Array();
for (var i=0;i<60;i++) {
objArray[i] = new myObj();

And then you'll have the array full of objects. Objects are much more powerful than structures. From your posted example, I'm guessing you're a ColdFusion developer -- objects are more like CFCs than regular old structures; however, they can be used just like structures in CF.

The above object can be accessed from the above array like this: