dee cheok dee cheok - 1 year ago 61
jQuery Question

put value into a object in order

var dataArray = [];

function setUpData (){

var dataObj = {name, address, age, phone};

dataObj[name] = name.val();
dataObj[address] = address.val();
dataObj[age] = age.val();
dataObj[phone] = phone.val();



i wanted to store my data to obj and then append into array , so i am append want the object to look like this name : jason , age : 27 , something like that, but i am having error doing this.

how i gonna to achieve that ?

Answer Source

create an array (exactly like you did):

var dataArray = [];

create the object you want:

var person = new Object(); = 'Jason';
    person.age = 35;

add it to the array

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download