This is what I have so far and the shoe types are boots, wellingtons, leather, trainers (in that order)
I want to iterate through and assign the value so I haves something like
var shoeArray = { boots : '3', wellingtons: '0', leather : '1', trainers: '3'};
at the moment I just get an array of {3,0,1,3}
which I can work with but it is not very helpful.
function shoe_types() {
var shoeArray = [];
$('[type=number]').each(function(){
$('span[data-field='+$(this).attr('id')+']').text($(this).val());
shoeArray.push ( parseInt($(this).val()) );
});
return shoeArray;
}
You can try this to create an associate array in jquery
This will allow you to send your all data whatever you want to pass in array by ajax.
What you want is a function that will return an object
{}
LIVE DEMO
Associative array in javascript is the same as object
Example:
Check this function
PS: Assuming
$(this).attr('id')
has all the shoe typesif
$(this).attr('id')
is the type of shoes you can try that