0

I need to extract the pricing data from a form. The form contain several dropdown options. All combo of options must be extracted.

Example of the form dropdown:

size => 1, 2, 3, 4, 5
type => 1, 2, 3, 4
color => 1, 2, 3
units => 1, 2, 3, 4, 5, 6, 7

So this particular product has 420 possible configurations size * type * color * units

How do I write some some sort of loop which will get all possible combinations?

TAG POS=1 TYPE=SELECT FORM=ACTION:/food/getPrice.do ATTR=NAME:size CONTENT=#1

By the way trying to use imacros to select an option by index as shown in the example above does not work. I am forced to select by specifying the value (such as: %1)

I also tried SET !DATASOURCE and imported a CSV file but it didn't loop through as I need it to.

--Just to clarify -- I need this kind of output (doesn't have to be in this order, but MUST output all possible combinations):

size => 1 type => 1 color => 1 units => 1
size => 1 type => 2 color => 1 units => 1
size => 1 type => 2 color => 2 units => 1
size => 1 type => 2 color => 2 units => 2
size => 1 type => 2 color => 2 units => 2
size => 1 type => 3 color => 1 units => 1
   . . .

--Side Note-- If you know of how I can run this imacro from a shared server (or EC2) please advise. Thanks for the help! :)

MrPizzaFace
  • 7,807
  • 15
  • 79
  • 123

1 Answers1

0

You're looking for the cartesian product, which is described here in PHP: PHP 2D Array output all combinations

Community
  • 1
  • 1
Armon
  • 358
  • 2
  • 9