Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2010, 04:41 PM
Authorized User
 
Join Date: Feb 2010
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Best approach for dynamic form

It's kind of difficuly to explain but I'll give it a try. I try to create a kind of workflow application. The user get's a question and depending on his answer he gets another question. This flow can become very complicated. What I need to do is create a dynamic form with (for example) a dropdown. when the user select something the next formfield appears, and so on, and so on.

At this moment I try to create the form with asp and hidden div's. When the user selects something another div is shown. But this approach is getting way to complicated. It ends up in a lot of if and case statements.

What can be a better approach in this sitiuation? I do not want refresh the whole page each time.

Maybe a wizard like solution will be better?

Last edited by hacking_mike; March 19th, 2010 at 05:51 PM..
 
Old March 19th, 2010, 06:40 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default ajax

Couple of things to consider:
1) I agree, don't refresh the page every time. All you want is to append to the DOM tree the next question, for example you can easily do this with jqeury and ajax;
2) Instead of keeping the logic in code, keep it in data. This way you can avoid nested if-else. Depend on the flow of questions, if it is tree like, keep it in XML, any data structure that reprents tree, JSON etc;
3) Whether to send the entire "tree" over in one shot or question by question (chunk by chunk). Chunk by chunk is in general better, and there might even be security reasons that you should not send the whole thing over in one shot...
 
Old March 21st, 2010, 06:43 AM
Authorized User
 
Join Date: Feb 2010
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by PeterPeiGuo View Post
Couple of things to consider:
1) I agree, don't refresh the page every time. All you want is to append to the DOM tree the next question, for example you can easily do this with jqeury and ajax;
2) Instead of keeping the logic in code, keep it in data. This way you can avoid nested if-else. Depend on the flow of questions, if it is tree like, keep it in XML, any data structure that reprents tree, JSON etc;
3) Whether to send the entire "tree" over in one shot or question by question (chunk by chunk). Chunk by chunk is in general better, and there might even be security reasons that you should not send the whole thing over in one shot...
Thanks, I'll sort it out an start a new thread





Similar Threads
Thread Thread Starter Forum Replies Last Post
help writing dynamic form data to dynamic table ublend SQL Server ASP 1 June 1st, 2007 08:09 AM
help writing dynamic form data to dynamic table ublend Classic ASP Professional 1 June 1st, 2007 08:08 AM
Dynamic Form Display Morn ASP.NET 2.0 Basics 0 March 13th, 2007 03:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.