I am working on this multipage form for a client. I followed this example because it seemed super easy: https://mtechwizard.com/how-to-create-multi-page-form-on-wix/
Every time I put the below code into the site this line came up with an error:
$w('#formIdInput').value = session.getItem('formId');
This is invalid-$w(‘#formIdInput’).value
This is the site code:
import {session} from 'wix-storage';
import {combineRows} from 'backend/multi-page-form';
$w.onReady(function () {
let formId = session.getItem('formId');
if (formId === null)
{
//Generate an unique id for the multi-page form
formId = Math.random().toString();
//Save the form id to browser session memory
session.setItem('formId',formId);
}
//Assign formId in session memory to the form on page
$w('#formIdInput').value = session.getItem('formId');
combineRows(formId);
});
This is no longer giving me an error
$w('#formIdInput').value = session.getItem('formId');
But it is still not working.
This is the back end code:
import wixData from 'wix-data';
export function combineRows (formId)
{
wixData.query('FormsMasterDatabase').eq('formId', formId).find().then
(
(result) => {
let rows = result.items;
let rowIds = [];
//Collect ids of the rows that need to be removed from collection
for (let row of rows)
{
rowIds.push(row["_id"]);
}
//Go through each row, and add the row data to the first row
for (let index = rows.length - 1; index >= 1; index-- )
{
//Go through each field in each row, and add field value to the first row
for (let field in rows[index])
{
if (rows[index][field] !== null)
{
//Assign field data on each page to the same field on the first page
rows[0][field] = rows[index][field];
}
}
}
//Remove all the rows from collection
wixData.bulkRemove('FormsMasterDatabase', rowIds)
//Insert the combined row (the first row) to collection
.then
(
(removeResult) => { wixData.insert('FormsMasterDatabase', rows[0]); }
);
}
);
}
No matter if I put ‘’ or “” or Forms Master Database or Form Id nothing changes
This is the url: https://elizabethjhay.wixsite.com/mysite-9
I need help asap. I am trying to make this live as soon as I can. We have just been having a time with Wix multi forms and I want to just start fresh.