Accessing variables amongst different fields

Accessing variables amongst different fields

I have a form that will allow a user to customize the options of an oven.  The oven has a customizable cook top that can have a pasta cooker or a griddle, or burners etc.  There is a total of 160cm of space available and each type of cook top has a given space, such as 120cm, 80cm, 60cm and 40cm.

When a certain oven model is selected, I wanted to set a variable called space_left = 160.  Then display dropdown for each size, so a dropdown for 120cm cook tops, 80cm cook tops, etc.  

When a user selects a 120cm cook top, it will only display the dropdowns  for sizes that will add up to 160cm.

For example, if a user selects a cook top of 120cm, it will remove the dropdowns for 120cm, 80cm, 60cm, becuase they would all be greater than 160cm if a user added one of them.

My question is:

When I set the variable space_left = 160 on the dropdown that selects the model, I cannot access it again. I want to be able to access it in the 4 different cooktop size dropdowns in order to subtract each size selected and determine which remaining dropdowns to display.

Is there a way to access a variable amongst different dropdowns?