For saving Respective Question Id, Name and it's answer
I am using below function in scripting
$scope.Save = function () {
var entry = {};
var details = new Array();
var options = document.getElementsByName('gender');
var option_value;
for (var i = 0; i < $scope.questionSet.length; i++) {
for (var j = 0; j < $scope.questionSet[i].Questionoptions.length; j++)
{
for (var k = 0; k < options.length; k++) {
if (options[k].checked) {
if (options[k].value == $scope.questionSet[i].Questionoptions[j].Options) {
var question = {};
question.QId = $scope.questionSet[i].Questions.QId;
question.QName = $scope.questionSet[i].Questions.QName;
option_value = options[k].value;
question.Answer = option_value
document.getElementById('selected').innerHTML += "<br>" + option_value;
details.push(question);
}
}
}
}
}
entry.details = details;
$http({
method: "Post",
url: "/home/Save",
dataType: 'json',
headers: { "Content-Type": "application/json" },
data: '{data: ' + JSON.stringify(entry) + '}'
}).then(function (result) {
})
}