943,199 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 716
  • ASP RSS
Jun 16th, 2010
0

Saving form data as an array

Expand Post »
I have a table of questions for a survey, each one with its identifying number. I have a form that populates with all the questions (this is not an exact number, as more can be added) but I need to store the results into one field, using arrays, because the number of columns for a table holding the results would need to change otherwise whenever a new question is added). I have never worked with arrays but I was told this was the way to do it. I need to store the yes or no answer for a question with its number identifying the question. I also need to know how do I pull it back when I need to display the results of a particular survey, as I would need to link the number of the question to the questions table to display the actual question, and then get the answer and display it too. I have no idea where to start.
My questions table(TA_Questions) has three fields: CategoryID, QuestionID, Question and the table that holds the results(TA_Surveys) has 3 fields: EventId, UserId, Answers(this is where I need to store all the answers to the survey which can be yes,no, or blank). So far there are 29 questions in the survey. In order to display the results I need to access the questions table to get the question using the QuestionID which ideally was stored with its answer in the answers field. Can anybody help me with this code?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pinkiguana is offline Offline
4 posts
since Jun 2010
Jun 17th, 2010
0
Re: Saving form data as an array
I think I need to simplify, I need sample code arrays to submit all the values of the radiobuttons which each group of Yes/No values is linked to a question Id, and store into one field in my database as a string (I am assuming this requires an array) and how to retrieve these linking the question Id to the question description to be able to display the submitted survey with the chosen answers that would exist in that field as paired values with its identifying Id. Any help will be greatly appreciated!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pinkiguana is offline Offline
4 posts
since Jun 2010
Jun 17th, 2010
0
Re: Saving form data as an array
It will be simple if there is always the same number of answers and in the same order, otherwise you will have problems with the position of the answers in the array.

To add the data to the array try:

strQ1 - Request("1")
strQ2 - Request("2")
strQ3 - Request("3")
strQ4 - Request("4")

strBuildArray = strQ1 & "," & strQ2 & "," & strQ3 & "," & strQ4

To get the data back from the array try:

strRecordArray = Split(strRecord, ",")
strA1 = strRecordArray(0)
strA2 = strRecordArray(1)
strA3 = strRecordArray(2)
strA3 = strRecordArray(3)
Reputation Points: 5
Solved Threads: 14
Junior Poster
ArtistScope is offline Offline
146 posts
since Jun 2010
Jun 17th, 2010
0
Re: Saving form data as an array
thank you for the reply. Actually, the questions populate from a table, and they have an id which is sorted in ascending, but the number of questions is not always the same as more questions could be added, some deactivated. I will try to see if I can follow what you have illustrated here for what I need.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pinkiguana is offline Offline
4 posts
since Jun 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: user defined Login control with authentcation
Next Thread in ASP Forum Timeline: AJAX accordion Pane problem in IE





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC