Solved it. I am using a GoHighLevel based CRM. This code was originally inserted into a hidden field. I moved the code to the Survey Footer which loads prior to the form fields. Seems to be working now!