I have a form where I dynamicly add three fields at time.
Those fields each have diffrent class names.
I want to create a multidimensional array that stores the values of those fields.
The array needs to look like this:
var working_days = {
0: {
'workday': data,
'from': data,
'till': data
},
1: {
'workday': data,
'from': data,
'till': data
},
2: {
'workday': data,
'from': data,
'till': data
},
//etc.
};
Prehaps using array push?
This is the code I have so far:
$('body').on('click','.createItem', function() {
var working_days = {}
console.log(values);
$('input.startTime').each(function() {
var startTime = $(this).val();
});
$('input.endTime').each(function() {
var endTime = $(this).val();
});
$('select.day').each(function() {
var day = $(this).val();
});
});
What are possible ways to do this?
question from:
https://stackoverflow.com/questions/65836475/how-to-create-a-multidimensional-array-with-values-from-dynamically-created-form 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…