Error returning data from JS array

Asked

Viewed 27 times

0

I need to assign the attributes to the object relatively, without knowing how many parameters will come, so it is not returning results, there is another method?

    var menu = document.getElementById("funcaoMenu").value;

    res = menu.split(","); //divide os resultados pela "," e cria um array


    oi = new Object(); // instância um novo objeto


    for (var i = 0; i < res.length; i++) {
        oi.i = res[i]; // recebe os dados do array e alterna a chave
    };

the data I receive are string parameters, for example: "menu","footer","hello".

and need to run this data in a php parameter to use the function and func_num_args and func_get_args.

  • You can give an example of the data you receive and the format you want to obtain?

1 answer

1


I think you should do the assignment like this:

oi[i] = res[i];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.