Refactored js for updating market selections.