How do you set a value to a hidden field with javascript?


I’ve added a hidden field to my survey.  I would like to set the value of the hidden field to a value I calculated in javasript.  How do I do this?



DataNerd1507 unselected answer

    This would help on how to find the the element ID so you can change the value

    Ivan Zh answered

      Hi Stephen,


      I wonder what you’re trying to accomplish ultimately? Setting a hidden value with javascript is not an ideal situation because hidden values don’t have classes. This is something better done using custom scripting.

      You would have to use the id or get incredibly generic and just target all hidden inputs.  Something like: $(‘input:hidden’).val(‘Stuff you want to write’);

      Or: $(‘#hidden-value-id’).val(‘Stuff you want to write’);

      The first line would only be recommended if there’s only one as it will target all hidden inputs.


      Hope this helps!

      DataNerd1507 unselected as best answer


        Question stats

        • Active
        • Views15549 times
        • Answers2 answers
        • Followers0 followers