As a form, each field is part of the FORM scope upon submit by default. This scope is a simple struct (i.e. FORM = {question_id: value, response_id: value}), from which you can easily reference each item: (for output) <cfoutput>#FORM.question_id#</cfoutput>.
So let's say you had 10 questions, and that there would always be an answer. First, you'd have a hidden form field for each question:
<input type="hidden" name="questionId_01" value="01" />
<input type="hidden" name="questionId_02" value="02" />
Notice each field has a different name. This is necessary to get a unique reference to each field. You then create corresponding input fields for each question. Say it was multiple choice questions, and you were using radio buttons. You'd create your fields with the same name but the choice values:
<input type="radio" name="responseId_01" value="a" />
<input type="radio" name="responseId_01" value="b" />
<input type="radio" name="responseId_01" value="c" />
<input type="radio" name="responseId_02" value="a" />
<input type="radio" name="responseId_02" value="b" />
<input type="radio" name="responseId_02" value="c" />
Submitting your form would pass these as simple name/value pairs to the server. I see the jQuery tag attached to your question (though you don't mention it), so I'll assume you're doing an Ajax submission. Most people use $.serializeArray() to put their form data in a format for ajax data. It's the simple way of handling it.
$('myForm').submit(function(e){
e.preventDefault();
$.ajax({
url: 'myProcessor.cfc?method=processForm&returnformat=JSON',
data: $(this).serializeArray(),
success: callbackFunctionName
});
});
Will post the following params:
questionId_01 01
questionId_02 02
responseId_01 b
responseId_02 a
method processForm
returnformat JSON
So, you don't have the array of structures you're looking for server-side yet. You can do some server-side processing to make your arrays by looping over the ARGUMENTS scope:
<cfscript>
LOCAL.processArr = ArrayNew(1);
for (LOCAL.i in ARGUMENTS){
if (FindNoCase('questionId',LOCAL.i)){
LOCAL.tmpArr = ListToArray(LOCAL.i,'_'); // get the Id to find response entity
LOCAL.tmpStr = {questionId = ARGUMENTS[LOCAL.i], responseId = ARGUMENTS['responseId_' & LOCAL.tmpArr[2]]}; // CF arrays start at 1
ArrayAppend(LOCAL.processArr, Duplicate(LOCAL.tmpStr));
}
}
</cfscript>
Now you have the array of structs you were looking for. You can then loop the array and perform your inserts.