title: Iterating throgh mvc model lists using javascript
body: <p>I want to iterate through my model values. Following is what I did to achieve this. But the varible count never increments. How can I increment it to iterate throgh my model values?</p>
  
  <pre><code>&lt;script  language="javascript" type="text/javascript"&gt;
       function AddStudentName() {
  
                      var StudentName = document.getElementById('txtStudentName').value;
  
                      StudentName= StudentName.replace(/^\s+|\s+$/g, '');
  
                      if(StudentName!= null)
                      {                
                        &lt;%int count = 0; %&gt;
                        for(var counter = 0; parseInt(counter)&lt; parseInt('&lt;%=Model.StudentInfo.Count%&gt;',10); counter++)
                        {
                          alert('&lt;%=count%&gt;');
                          if('&lt;%=Model.StudentInfo[count].StudentName%&gt;' == StudentName)
                          {
                            alert("A student with new student name already exists.");
                            return false;
                          }
                          &lt;%count = count +1;%&gt;
                        }
                      }
                  }
      &lt;/script&gt;
  </code></pre>
  
  <p>thanks,
  Kapil</p>