fixes #478 - generate hidden and JS code to populate selection field