How do I populate a selectable catalog variable with an array from a catalog client script

David Dunleavy
Tera Expert

In a Catalog Client Script I find an available IP Address.   Currently when I find it I put in a Single Line Text variable.   I want to find N number of available IP addresses and populate all N in a catalog variable AND have the user be able to select 1 from that list.

I can create the array to send back.  I cant find a variable type that will accept, display and allow the selection of one item from that list.

A multi-line text box displays them all but is not selectable. 

A list collector doesnt work nor does any variable where I have to select from a table.   I want to populate the value from my Catalog Client Script not a table.

 

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi David,

Have you tried a Select Box type variable?  You would not add any Question Choices when defining the variable as is typically done, rather at the end of your Catalog Client Script (onLoad or onChange), just loop through the array adding each to the list.  That would look something like this:

g_form.addOption('v_service_area','',' -- None --');
for(var i=0;i<answer.length;i++) {
  g_form.addOption('v_service_area',answer[i],answer[i]);
}

Where 'v_service_area' is the name of the variable in this case.  The first line is so that the first choice added is not automatically selected.  'answer' is the array returned from a Script Include or however you're doing it.  The assignment is repeated in the addOption arguments as a label and value are recommended/required.

View solution in original post

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Hi David,

Have you tried a Select Box type variable?  You would not add any Question Choices when defining the variable as is typically done, rather at the end of your Catalog Client Script (onLoad or onChange), just loop through the array adding each to the list.  That would look something like this:

g_form.addOption('v_service_area','',' -- None --');
for(var i=0;i<answer.length;i++) {
  g_form.addOption('v_service_area',answer[i],answer[i]);
}

Where 'v_service_area' is the name of the variable in this case.  The first line is so that the first choice added is not automatically selected.  'answer' is the array returned from a Script Include or however you're doing it.  The assignment is repeated in the addOption arguments as a label and value are recommended/required.