Using units (resources) from my database

Hi all,

I would like to call and then populate the resources from my database using the units view, but not sure how I would go about it.

For example:

How do I loop through my record set to populate the sections array:

This is what I have hard coded:

var sections=[
			{key:1, label:"Andy Bravo"},
			{key:2, label:"Stu Biggins"},
			{key:3, label:"Steve L"},
			{key:4, label:"Jay M"}
		];

I would like to try and do something like this:

var sections=[
     for (var i=0;i<iResourceCountFromDB;i++){

			{key:i, label:RecordSet.ResourceName[i]},
    }
];

Any help on how to populate the sections array would be very much appreciated.

Jay/

The component is fully client side, so it can’t load data directly from DB, but you can server page as dynamic one ( PHP, JSP etc. ) , which will allow to include server side code in it.

var sections=[]; <% for (var i=0;i<iResourceCountFromDB;i++){ print("section.push({key:"+i+", label:\""+RecordSet.ResourceName[i]+"\"});"); } %>

Thank you so much for your reply.

I do not use any server side scripts (Complicated secure setup :slight_smile:), however I will certainly try the “Push” technique when I loop through the AJAX - That has given me a way to add to the array via JS (I hope).

Thanks again.