0

I am reciving the formValues object, and when I console.log it, I get this result:

attribute_0: "2478"
attribute_1: "2475"
attribute_2: "2480"

What I need is to take those values and store it in a hidden input field, to have something like this:

<input type="hidden" value="2478,2475,2480">

And I could do it, but somehow I can't access this properties in a for loop, so not to do it like:

formValues.attribute_0;
formValues.attribute_1;
formValues.attribute_2;

Because it will be a lot of this attributes, so I need something like:

var attributeValues = '';
for (var i = 0; i < 3; i++) {
   attributeValues += formValues.attribute_{i};
}

Or

var attributeValues = '';
for (var i = 0; i < 3; i++) {
   var text = 'attribute' + i;
   attributeValues += formValues.text;
}

But no. Undefined is what I get :(.If anyone knows how to deal with this kind of stuff, help will be most appreciated.

user2450639
  • 196
  • 1
  • 14

0 Answers0