Is it possible to take the contents of a variable and stick it into an array like so (I've tried to no avail):
First I get these values from a database and using php form into a hidden input:
{value: '1', name: 'name1'},{value: '2', name: 'name2'}
Then collect with javascript
document.getElementById("myelement").value
Then put the value
var meval = document.getElementById("myelement").value;
And then I try to build the data like so:
var data = {items: [meval]};
If I do this
var data = {items: [{value: '1', name: 'name1'},{value: '2', name: 'name2'}]};
it works but not the initial way with the variable. And I have to build the original data like that.