title: Pass values from the For loop to JavaScript
body: <p>I'm creating a survey form using ASP.NET MVC architecture.</p>
  <p>There is a section where I load the questions for the survey from a model to the view.</p>
  <p>The model created as</p>
  <pre><code>[NotMapped]
      public class QuizForService
      {
          public int MainDetailsId { get; set; }
          public int QuizID { get; set; }
          public string Quiz { get; set; }
          public string AnswerForQuiz { get; set; }
      }
  
  </code></pre>
  <p>So from the controller, I load the Questions to this model</p>
  <pre><code>List &lt; QuizForService &gt; Questionsto = (from q in db.tbl_QuestionsSub 
                                         where q.ServiceTypeId == ServiceId select new QuizForService 
                                         {
                                          QuizID = q.Id,
                                          Quiz = q.QuestionEng
                                         }).ToList();
  
  return Json(new {
    Success = true,
      questionlist = Questionsto,
  
  }, JsonRequestBehavior.AllowGet);
  
  </code></pre>
  <p>So in the view, I load the question from <code>for</code>loop and the answer list to select users to the related question.</p>
  <pre><code>for (int i = 0; i &lt; SurveyList.Count; i++) {
    &lt; tr &gt;
      &lt;
      td &gt; @SurveyList[i].Quiz &lt; /td&gt; &lt;
      td &gt; @if(@SurveyList[i].QuizID != 8) {
        @SurveyList[i].AnswerForQuiz &lt; div class = &quot;radio&quot; &gt;
          &lt;
          input label = &quot;Excellent &quot;
        type = &quot;radio&quot;
        id = &quot;Excellent&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Excellent&quot;
        checked &gt;
          &lt;
          input label = &quot;Good &quot;
        type = &quot;radio&quot;
        id = &quot;Good&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Good&quot; &gt;
          &lt;
          input label = &quot;Fair &quot;
        type = &quot;radio&quot;
        id = &quot;Fair&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Fair&quot; &gt;
          &lt;
          input label = &quot;Poor &quot;
        type = &quot;radio&quot;
        id = &quot;Poor&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Poor&quot; &gt;
          &lt;
          /div&gt; } else { &lt;div class=&quot;radio&quot;&gt; &lt;
          input label = &quot;Yes &quot;
        type = &quot;radio&quot;
        id = &quot;Yes&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Yes&quot;
        checked &gt;
          &lt;
          input label = &quot;No &quot;
        type = &quot;radio&quot;
        id = &quot;No&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;No&quot; &gt;
          &lt;
          input label = &quot;Maybe &quot;
        type = &quot;radio&quot;
        id = &quot;Maybe&quot;
        name = &quot;@SurveyList[i].QuizID&quot;
        value = &quot;Maybe&quot; &gt;
          &lt;
          /div&gt; } &lt;/td &gt;
          &lt;
          /tr&gt;
  
  </code></pre>
  <p>So the view is a single-page application and the process goes like a wizard.</p>
  <p>I thought of submitting get those values using javascript and passing it to the controller using Ajax.</p>
  <p>I want to know how to get those question IDs with the customer selected answer to the javascript.</p>