Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginners question. Whats the best way...

Status
Not open for further replies.

cawthor

Programmer
May 31, 2001
89
US
I have a very large input form (for a user to fill out and submit). I wanted to break this form up into multiple pages (eg, stage 1...stage 2...etc). What is the best way to do this...would I just pass all the values as 'hidden' input types between the pages? By stage 5, this could be quite messy...is there a better way to do this? Database for example?

Thanks.
 
using hidden fields would be the easiest wand quickest way to it up and running. check this thread for examples on doing this
thread329-310055

using the database would be something I would prefer to do but if the form is that exstensive your speed will be effected slightly.

If you have the capability of using asp (obviously you do)
creating session variables would be another alternative. That would be the cleanest way.
example
session("field1") = form1.text1.value

then if you wanted to populate a final page for the entire form to view and submit
<input type=&quot;text&quot; name=&quot;text1&quot; value=&quot;<% session(&quot;field1&quot;) %>&quot;>

[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
I'm not sure how busy this web site will be but I would like to give you a heads up about using Session variables to hold this data. The built in Session object with ASP is not used often in production strength applications because of a serious scalability issue. Your application will not work well in a web farm if you ever get to the point you need this additional power.

You state you are a beginner to asp. It is my guess this application you are building will never need to be hosted in a server farm so using session state probably wouldn’t hurt. I’m sure someday you hope to be developing more robust applications so why not get into the habit of thinking in these terms from the beginning. I suggest you find a way to accomplish your task without using asp’s Session state.

I prefer to store data in a database whenever possible but that may not be the best approach here. I like the idea of having hidden fields and then only update the database after the last page has been completed. The advantage I see here is if the user never completes all five pages, you don’t have partially completed information. You should also program for the possibility users will come in on the 2nd, 3rd, 4th or 5th page and not assume they will always start with page 1.

Thanks,

Gabe
 
Hi cawthor!

It is probably the best to work with Session variables. However, if you write hidden input tags, you will have the benefit that the page will work even if someone will turn the &quot;cookies off&quot; on his browser, but as you saw yourself the code becomes very messy.
For large forms with many fields, it can be useful if you would use the same name for every input field except put a number after the field name like data1, data2, data3... datan, and use Arrays instead of writing out all different variable names (like firstname, lastname, address, etc.), so later when you process your input values, you can use &quot;for...next&quot; loops with arrays to transfer data between your variables and/or databases using just a few lines of code what makes it more elegant and easy to maintain (you have to be careful with the order of the input items on page though).
It is also advisable to save data in a database when all forms are done, so you do not have to worry about deleting those records what are not completed.

In addition, it could be a good way - but a bit though thing to program - to store data in an XML object and use this object later squeeze the data from.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top