surveyjs

Can I override survey field value with one from URLSearchParams?


Is there a way to override a field value with one parsed from URLSearchParams? I'd like to fill an hidden field if a specific parameter is passed by the URL.

E.g. JSON part

{
"type": "text",
"name": "year",
"width": "100%",
"minWidth": "256px",
"title": "Year:"
}

URL similar to xxx.com?year=1999

In this way I'd like to fill year with 1999.


Solution

  • If you wish to fill the 'Year' input field with a URL parameter value, retrieve a URL parameter value and call the survey.setValue('year', 1999) function to fill a question's value.