Skip to main content
deckarduk
Inspiring
July 27, 2022
Question

Creating an array, help required please...

  • July 27, 2022
  • 1 reply
  • 1314 views

Hi there,

I've written some code to create a combo box and all works fine in JS debugger.

The values for the combo box are passed in via an array like this:

var aOptions = new Array('Choose an Item','Apple','Pear','Banana','Grape','Orange');

I'm now trying to pick up the values from a text field, on a form, and generate the combo box.

I've tried a number of different ways to take the values from the text field and generate separate combo items. The value taken from the text field ends up as one big item.

I've tried splitting down the values from the text field in a number of ways, for example using a comma to separate them, but as yet haven't succeeded in generating separate combo box items.

 

As mentioned earlier, the code above works fine in the debugger it's when I try to pick up the values from a text field I'm having issues.

Please can someone point me in the right direction.

 

Thanks in advance.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 27, 2022

Post your code, please.

deckarduk
deckardukAuthor
Inspiring
July 28, 2022

Hi Gilad,

Thanks for your response.

 

I'm picking up the parameters from 2 form elements, already on the page, as shown below and then passing them to the combobox creation. The JS that picks up the form values, and passes them to the code that generates the combo box, is the action in a Submit button.

The code works fine apart from the combo box values being picked up as one chunk rather than individual values from the text field.

var listBoxName = this.getField("fieldName").value;
var listVals = this.getField("listBoxVals").value;

var inch = 72; // points per inch
var page = this.pageNum; // zero based page for field
theFieldName = listBoxName;
var aOptions = new Array(listVals.split('\r'));


// GENERATE COMBO BOX...

 If I use the code below in the debugger it works fine: 

theFieldName = 'comboBoxName123';
var aOptions = new Array('Choose an Item','Apple','Pear','Banana','Grape','Orange');

I'm thinking it has something to do with passing the parameters via form fields rather than from the debugger?

Thanks again for the help 🙂

try67
Community Expert
Community Expert
July 28, 2022

This code is very partial. Please post the full code, and maybe the file itself, for help with it.