Move custom states among 5 different pages

Hei guys here my question

I m creating a survey that is made of 3 questions each for 5 consequences pages. Each question in each page has a specific custom state that is filled once the user is answering to the question.
I want to bring the custom states of each page until the 5th page where finally these temporary information will be written in the DB.

How would it be possible?

Here the example:
Page 1: when the questions are anwered I ll have:

  • Answer 1: Custom State 1
  • Answer 2: Custom State 2
  • Answer 3: Custom State 3

It will be the same for the next 4 pages. At the end of the 5th page I want user to press a button and this button will finally write in the DB all the answers he/she made.

Custom states exist (by definition) only on the page they are on. The’y can’t be used to transfer data from one page to another.

If you need to transfer data between pages, you’ll need to use another method, such as:

  • Database storage
  • Cookies
  • Local/Session storage
  • URL parameters

…depending, of course, on your specific use case.

But, from what you’ve described you’re trying to do, I’m not sure why you need to use custom states anyway (ignoring the fact that you can’t)… why not just store the data directly in the database, as that’s where it will end up?

Because it is super slowing down the user experience of the user to store it directly - the user has to be already in a survey of 5 minutes. Writing directly is slowing down the process.

So is it not possible to do something?

I was seeing this post here: Is there a way to bring or reference a CUSTOM STATE in another page? - it seems doable but not sure if it is between multiple pages.

Simple answer - don’t have multiple pages !

2 Likes

Because it is super slowing down the user experience of the user to store it directly

Writing to the database is slower than loading a new page?!!

It shouldn’t take any noticeable time at all to write 3 fields to the database for a single thing…

And certainly that should be much faster from the User Experience than loading a whole new page every time…

So is it not possible to do something?

Yes, it’s possible to do many things, including what I said in my first answer:

  • Database storage
  • Cookies
  • Local/Session storage
  • URL parameters

What I (and others) said in the other thread you linked to was just to use URL parameters - but I certainly wouldn’t recommend that for your use case here.

It’s not possible to use custom states between pages (that’s not what they’re for, of how they work).

But, as @NigelG points out, why do you need to use 5 separate pages for this? Surely that’s the worst, and slowest UX possible for the User (not to mention 5 times more work to build and maintain).

Can’t you just use a single page? With a 5-stage form? Then you can use custom states as much as you like if you really need to (although you wouldn’t need to then, as you can just access the input values directly).