Multi-Step form with conditional step, saving to database, without refreshing the page?
I used this oldish article to create an MVC form that successfully pages through the steps of a five-step form but I've run into issues that, thanks to my poor understanding of MVC and forms in general, I'm not able to get past.
The page refreshes each time I page through the form, which isn't good when there's a lot of content to scroll through in order to get to the form.
I can't make a conditional step (as in, if Option B is chosen on Step 1 it goes to Step 2, but if options A or C are chosen it skips to Step 3) that functions properly.
I'm unable to preserve the content throughout the form so that I can send it all to a database at the end, since the article I used as a guide sort of skips that part under the assumption that a developer would know what they're doing. Since I don't know what I'm doing, the content for the fields in the last step of my form get sent to the DB just fine, but everything else is empty.
I've been looking around for days now and I'm unable to find any answers that I can translate to my code. As I said, I'm not good at MVC and I'm probably never going to be especially familiar with what's going on in MVC code, so it's harder for me to find answers out of context.
I could provide my code, but it is essentially just the linked article plus a few more steps added - nothing special or complex.
I think that for your particular use case, it might be worthwhile looking at creating a multi-step form by using Javascript and MVC.
Basically, you can create a single model, view and controller. The view itself will, by default, show all the input fields. Then, using Javascript, you can control which fields appear at what times.
There's an example guide here. Similarly, there's a nice plugin called jQuery Steps that makes all of this super easy.
If you're using the Javascript solution, then:
The page won't need to refresh (thus no scrolling down again)
You can create optional / conditional steps a bit easier
The content will be preserved throughout the form
The only downside is that the data will only be submitted and saved at the end, so if a user gives up halfway, then you won't get any of their information. Whilst this isn't a big deal generally, since it's an incomplete submission, it might be something you want to consider.
Multi-Step form with conditional step, saving to database, without refreshing the page?
I used this oldish article to create an MVC form that successfully pages through the steps of a five-step form but I've run into issues that, thanks to my poor understanding of MVC and forms in general, I'm not able to get past.
I've been looking around for days now and I'm unable to find any answers that I can translate to my code. As I said, I'm not good at MVC and I'm probably never going to be especially familiar with what's going on in MVC code, so it's harder for me to find answers out of context.
I could provide my code, but it is essentially just the linked article plus a few more steps added - nothing special or complex.
I think that for your particular use case, it might be worthwhile looking at creating a multi-step form by using Javascript and MVC.
Basically, you can create a single model, view and controller. The view itself will, by default, show all the input fields. Then, using Javascript, you can control which fields appear at what times.
There's an example guide here. Similarly, there's a nice plugin called jQuery Steps that makes all of this super easy.
If you're using the Javascript solution, then:
The only downside is that the data will only be submitted and saved at the end, so if a user gives up halfway, then you won't get any of their information. Whilst this isn't a big deal generally, since it's an incomplete submission, it might be something you want to consider.
Hopefully this helps!
Great suggestion! I got my form working with the javascript solution, so thank you.
is working on a reply...