title: setting td inner text through script called in razor
body: <p>I want to do something like this within my view (razor)</p>
  
  <pre><code>if(index == @:{&lt;script&gt;{getPosition(@geResult.assessmentId);}&lt;/script&gt;}){
       geResult.ResultValue;
     }
  </code></pre>
  
  <p>What will be the proper syntax?</p>
  
  <p><strong>Full HTML</strong></p>
  
  <pre><code> &lt;tr&gt;
   @{
      var index = 4; 
      foreach(Assessment geAssessment in Model.assessments)
       {
       &lt;td&gt;
        @foreach (ShortResult geResult in Model.results)
        {
         if(geResult.StudentID == geStudent.studentid)
         {
           if(index == @:{&lt;script&gt;{getPosition(@geResult.assessmentId);}&lt;/script&gt;} ){
          geResult.ResultValue;
          }
        }
      }
     &lt;/td&gt;
     index++;
     }
    }
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I am trying the other way round now can anyone guide me please</p>
  
  <p><strong>SCRIPT</strong></p>
  
  <pre><code>   function getPosition(id, colIndex) {
  
      var element = '#' + id;
      $(this).closest('tr').find('td').eq(colIndex).html("A");
      alert($(this).closest('tr').find('td').eq(colIndex).html());
      return $(element).index();
  
    }
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code> &lt;td&gt;
     @foreach (ShortResult geResult in Model.results)
       {
        if(geResult.StudentID == geStudent.studentid)
        {
         &lt;script&gt;{ getPosition(@geResult.assessmentId, @index); }&lt;/script&gt;
       }
       }
   &lt;/td&gt;
  </code></pre>
  
  <p>now the alert returns undefined although i am setting its value (text) just before!!</p>