title: Using Razor and javascript within each other
body: <p>I want to use a javascript variable in Razor like this :</p>
  
  <p>my html:</p>
  
  <pre><code>@{List&lt;AddTempViewModel&gt; tempsToView = new List&lt;AddTempViewModel&gt;();
    tempsToView = (List&lt;AddTempViewModel&gt;)ViewData["tempsToView"];}
  
  @if (tempsToView != null)
  {
      @foreach (var item in tempsToView)
      {
         &lt;a class="click" id="@item.TempDocumentId"&gt;
         &lt;img id="leftSideBarElement" src="@item.TempDocumentAddressUrl" /&gt;
         &lt;/a&gt;&lt;br /&gt;
      }
  &lt;form method="post" action=""&gt;
     &lt;input id="documentNumber" class="form-control" type="text" name=""  
       placeholder="Email" /&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>and my script :</p>
  
  <pre><code>&lt;script&gt;
  
      $(document).ready(function () {
          $(".click").click(function () {
              var divID = $(this).attr('id');
              alert(divID);
              var docName = @tempsToView[divID].TempDocumentId
              $("#documentNumber").val(docName);
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>but I can't set the index of @tempsToView with divID.
  please help me what to do except this.
  thank you.</p>