// TODO: Set these to your own values
const clientId = 'YOUR_CLIENT';
const flowId = 'YOUR_FLOW_LABEL';
const variantId = 'YOUR_VARIANT_LABEL';
let flow_url = "https://flow.formsort.com"
flow_url += `/client/${clientId}`;
flow_url += `/flow/${flowId}`;
flow_url += `/variant/${variantId}`;
"cat_color": ["gray", "brown"]
const handleFormRedirect = (e) => {
const form = document.createElement('form');
// 2. Add the answers as <input type=hidden>
Object.keys(answers).forEach((key) => {
// If the answer is an array, add as <select> with <options>s
if (Array.isArray(answers[key])) {
const select = document.createElement("select");
answers[key].forEach((answer) => {
const option = document.createElement("option");
select.options.add(option);
form.appendChild(select);
// If the answer is a single value, add as an <input>
const input = document.createElement("input");
input.value = answers[key];
document.body.appendChild(form);
// 3. Submit the form instance
<a href="" onclick="handleFormRedirect(event)">Start flow</a>