Referencing lookup checkboxes

I have a checkbox field (field1) using a select lookup that gives maybe 40 possibilities. These will change depending on other parameters. I can grab the array and explode and then reference each checkbox with [0], [1] etc. I want to click a radio button (field2) and have that check options in field1, but since the elements in the array of field1 change, other than the field1 label I don’t know how to reference the correct field1 checkbox. How would I reference this to set it to checked?