Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Updating hidden field with javascript. The value doesn't submit.

Vote:
 

I've got a couple of Hidden fields where I'm setting the values with jQuery but the values don't come through in the submission.Data array.

I can see in the browser dev tools that it is set.

Any clues? 

#205482
Jul 12, 2019 22:11
Vote:
 

Hi,

Your fields are Pre-defined hidden element blocks or custom hidden element blocks (inherit from HiddenElementBlockBase) ?

And how do you set those values, on page load or right before xhr request is sent ?

#205545
Edited, Jul 16, 2019 10:13
Vote:
 

Hi Kenny,

I've given it a try with an Alloy site with forms added and tried modifying the value of a hidden field via JavaScript and it posted the data correctly for me. To follow on from what Quan said, I wonder whether the issue is that the data is being posted before the value is being updated.

#205567
Jul 16, 2019 17:12
Vote:
 

Sorry for the late reply, I had to reinstall everything on my laptop and we've been moving out of our house. :( 

These were custom hidden element blocks updated during page load. I was able to workaround the issue by storing the value in a cookie and then using a FormElementBlock that reads the cookie.

#205946
Jul 29, 2019 19:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.