For Loops

liunx

Guest
Hi, I need help with syntax:

I have an ASP page that shows the survey (question1/Answer1, question2/answer2, etc...), I also have a field that holds the number of question for this survey.

How do I structure a for loop so that each question/answer pair would be written to the database in a new record?

Here is what I put together. Please Help!!!

For n = 1 to varNumberOfQuestions
RS.AddNew

varQuestionNumber= TRIM(Request.Form("txtQuestion & n &")) 'retrieves question number one at a time
varAnswer= TRIM(Request.Form("txtAnswer & n &")) 'retrieves answer for the question
RS("QuestionNumber") = varQuestionNumber 'writes question # to DB
RS("Answer") = varAnswer 'writes answer to DB

RS.Update

Next

As you can see I am not that strong in coding...

Thanks a lot,
Juls.
 
Top