Pass option's value to hidden field | Community
Skip to main content
Answered

Pass option's value to hidden field


Forum|alt.badge.img

In my survey, I have set up a hidden field called 'surveyflag'. There is a multi choice in the survey. My question is: Can I set a value for each of the two options, such as Option A = 1, Option B = 2, and then pass the value to the hidden field when the survey is submitted?

Best answer by john.desborough

@RenataChang - the choice the user makes of dvd or book is going to be passed as part of the name/value pair that looks like this: 

  • q1_text = DVD 

it’s already available to the API

if you want to pass it as a variable, you simply need to create a custom variable NOT a hidden variable 

tthen you use the logic rules to replace the value of the variable you create with the output from the question choice 

here’s an example: 

you can create the variable (i used v_example) and used the replace function to set the value of the variable with the hardcoded text line

you would have to do this with every option - ie create a logic rule

 

you don’t need to do this if you can pass the question_text/choice name pair from the submit function 

 

des

View original

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • October 30, 2023

Hi @RenataChang Happy Monday! I hope you had a great weekend. 😀

Are you sending the data from the hidden field out of the survey? Or are you trying to have the hidden field value captured with their response in the Typeform results? 


Forum|alt.badge.img

@Liz  Thanks for the response.
It’s the second one, I'm not sure if Typeform can do this right now.


john.desborough
Forum|alt.badge.img+6

@RenataChang - if you are capturing the response in the typeform/question, there is really no need to add it to a hidden field. 

If you are passing the data from an external source (ie CRM/ESP) and you want to pass in, for example, the email of a subscriber, you would do that in the url with the name=value in the url. in the typeform, you would create a hidden variable called the same name as in your url string and it would act as the recipient of the data value. 

on submit, both the answers to questions AND a hidden variable passed into the form are recorded 

 

des


Forum|alt.badge.img

@john.desborough

I forgot to mention that because I have set up a webhook, the API needs to receive the same field name’s result. That's why I set up a hidden field in the survey first and tried to populate the hidden field with the user's response when they submit the survey and send it to the API. I apologize for not explaining clearly earlier and causing confusion.

So the situation isn't about passing values to Typeform from an external source first. The hidden field value I set up must be extracted from the results of this question and sent to the API.

 


john.desborough
Forum|alt.badge.img+6

@RenataChang - the choice the user makes of dvd or book is going to be passed as part of the name/value pair that looks like this: 

  • q1_text = DVD 

it’s already available to the API

if you want to pass it as a variable, you simply need to create a custom variable NOT a hidden variable 

tthen you use the logic rules to replace the value of the variable you create with the output from the question choice 

here’s an example: 

you can create the variable (i used v_example) and used the replace function to set the value of the variable with the hardcoded text line

you would have to do this with every option - ie create a logic rule

 

you don’t need to do this if you can pass the question_text/choice name pair from the submit function 

 

des


Forum|alt.badge.img

@john.desborough Thank you for the support, I will try this out.


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • October 31, 2023

Let us know how it goes @RenataChang !


Hi, all-

I’m new here, so I hope that you will see this tag-on to an older thread.

I want to do a survey, as follows: I have 45 questions, each question has two possible answers, and the respondent has to pick one of the two possible answers. Each answer falls into one of six categories.However, when respondents choose an answer, I don't want them to know the category that answer falls into, so I want to assign a category to each of the answers, but have that category be invisible to the respondent. Then, after the respondent has responded to all 45 questions, I want to be able to tally up how many answers fall into each of the six categories, for that respondent.

Based on this thread, it looks like I can do that with a variable. But I’m not sure if the respondent will be able to see the variable. Is the variable invisible to the respondent?

 

If it is visible, how do I pass along the needed data invisibly in Typeform? And is that capacity available at the Basic level?

Thanks!


john.desborough
Forum|alt.badge.img+6

@vorkosigan1 - create two custom variables, one for each category. Then use the logic rules in each question to assign a point to the appropriate variable. something like this

  • if q1 = A then add 1 to v_category1
  • if q1 = B then add 1 to v_category2
  • etc

then you can display the results use the @variable name  syntax

 

des


Thanks, des! And the respondent won’t e able to see any of that, correct?


Thanks, again!


john.desborough
Forum|alt.badge.img+6

@vorkosigan1 - they only see it if  you show it. 

 

des


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • February 27, 2025

Hi ​@vorkosigan1 I hope you’re doing well! How did the variables go for you? Let us know if you still need some help!


Reply