I have the following example data in javascript:
var variations = [
{group: 1, id: 1},
{group: 1, id: 2},
{group: 1, id: 3},
{group: 1, id: 4},
{group: 2, id: 5},
{group: 2, id: 6},
{group: 2, id: 7},
{group: 3, id: 8},
{group: 3, id: 9}
];
Let us say I already define the selection using the following variables:
var selected_variation_groups = [1,2,3];
var selected_variation_group_ids = [1,2,3,4,5,6,7,8,9];
When I try to find the selection number possibilities from above data, then I would have 24 posibilities:
=> 1, 5, 8
=> 1, 5, 9
=> 1, 6, 8
=> 1, 6, 9
=> 1, 7, 8
=> 1, 7, 9
=> 2, 5, 8
=> 2, 5, 9
=> 2, 6, 8
=> 2, 6, 9
=> 2, 7, 8
=> 2, 7, 9
=> 3, 5, 8
=> 3, 5, 9
=> 3, 6, 8
=> 3, 6, 9
=> 3, 7, 8
=> 3, 7, 9
=> 4, 5, 8
=> 4, 5, 9
=> 4, 6, 8
=> 4, 6, 9
=> 4, 7, 8
=> 4, 7, 9
Is there anyone who can help me to give the algorithm for this, or is there anyone who can help me provide javascript code to create those possibilities?
The group
s and id
s can be unlimited.