# I'm using multi step form its working fine but the problem is when I have filled first step and going to next step then for some reason I come back to previous step the data which I filled has been cleared how can I manage this problem

**URL:** <https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124>\
**Category:** Ask us anything\
**Created:** [October 30, 2023, 12:10pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124 "2023-10-30T12:10:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [October 30, 2023, 12:10pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/1 "2023-10-30T12:10:57Z")

</div>

I’m using multi step form its working fine but the problem is when I have filled first step and going to next step then for some reason I come back to previous step the data which I filled has been cleared how can I manage this problem

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [October 30, 2023, 1:42pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/2 "2023-10-30T13:42:12Z")

</div>

You need to save the data in a variable and set the variable as init value. Otherwise, do not use conditional display, but only display none.

The issue is, that when the step is hidden, it also gets destroyed, and then when you go back, it gets “rebuilt”, but at that time, it has no context or clue about what was stored in the previous element.

---

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [October 30, 2023, 1:45pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/3 "2023-10-30T13:45:56Z")

</div>

@Broberto At first I also got the same idea of ​​storing it in a variable, but I thought there might be an easier way, **Thanks** anyway.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [October 30, 2023, 1:51pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/4 "2023-10-30T13:51:32Z")

</div>

If you have the control over the how the each step is displayed/hidden, you can use display style property instead of conditional render and that might retain the data, as it would not destroy the fields, just hide them.

---

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [October 30, 2023, 5:53pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/5 "2023-10-30T17:53:52Z")

</div>

Great @Broberto ,this is best solution ,thanks again

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [October 30, 2023, 11:34pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/6 "2023-10-30T23:34:56Z")

</div>

Hi @vikas 👋

+1 on @Broberto’s suggestions!

Just keep in mind that, when you use the CSS `display` property, [the browser still renders the elements that are hidden](https://docs.weweb.io/css-and-styling/conditional-rendering.html#conditional-rendering-vs-display-none).

That’s fine if your multi-step forms don’t contain too many elements.

If you add more and more elements on the page and you notice the browser starts lagging, conditional rendering will be your friend 🙂

---

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [October 31, 2023, 2:53am UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/7 "2023-10-31T02:53:29Z")

</div>

Hi @Joyce  
Yes it contains the many elements. So the solution is to make variable for each and perform conditional rendering ?

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [October 31, 2023, 3:35pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/8 "2023-10-31T15:35:23Z")

</div>

Hi @vikas 👋

If you have many elements, yes, I think it can be a good option to save the answers of the users in a variable.

That said, instead of having one variable per input (which can add up to a lot!), you could have an object variable that you update with new inputs each step of the way.

For example, here we have `userAnswers` variable with empty default values except for the form step the user should start on:

 ![CleanShot 2023-10-31 at 16.32.38@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6faf2a24e5c9d15b8d643a831145cca7b437bcdf.png)

Then when the user clicks on the button to navigate to the next step, we add 1 to the step they were on and update the object with the input values from that step:

 ![CleanShot 2023-10-31 at 16.33.59@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d77fbac006971b913f6e9b203b05f377ac3b5f66.png)

Does that make sense?

---

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [October 31, 2023, 3:38pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/9 "2023-10-31T15:38:26Z")

</div>

@Joyce ,yes that’s what I did.  
But Upload file Inputs are still clearing I’m unable to set the Init value for the same could you please guide me on this @Joyce

Thankyou…

---

<div class="post-metadata">

**Author:** ![vikas](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@vikas](https://community.weweb.io/u/vikas)\
**Post date:** [November 1, 2023, 2:47am UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/10 "2023-11-01T02:47:37Z")

</div>

Hi @Joyce  
Upload file Inputs are still clearing I’m unable to set the Init value for the same could you please guide me on this.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [November 2, 2023, 11:35am UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/11 "2023-11-02T11:35:02Z")

</div>

Hi @vikas 👋

Can you share a screen recording of how you set things up on your side and where you’re stuck?

---

<div class="post-metadata">

**Author:** ![vic](https://avatars.discourse-cdn.com/v4/letter/v/9e8a1a/32.png) [@vic](https://community.weweb.io/u/vic)\
**Post date:** [January 4, 2024, 11:10pm UTC](https://community.weweb.io/t/im-using-multi-step-form-its-working-fine-but-the-problem-is-when-i-have-filled-first-step-and-going-to-next-step-then-for-some-reason-i-come-back-to-previous-step-the-data-which-i-filled-has-been-cleared-how-can-i-manage-this-problem/5124/12 "2024-01-04T23:10:43Z")

</div>

Hi @joyce I think I see what they’re referring to, when using a file upload input there is not an init or initial value to set. Is there any workaround for this?

 ![Screenshot 2024-01-04 at 4.10.30 PM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/66993824c06e59409a9f12755e96b7023fc2401a.png)
