title: Is there a way to use javascript variable inside Laravel blade template?
body: <p>I  will automatically create the rows of a table in jQuery . by clicking addRow button , function addRow() will do it like below:</p>
  
  <pre><code>function addRow(){
  
    var rowCount = $("table tr").length - 1; 
    var row = '&lt;tr&gt;&lt;td&gt;&lt;input name=“item[‘+ (rowCount+1) + ']" type="text" value="{{ old(‘item') }}”&gt; @if ($errors-&gt;has(‘item’)){{ $errors-&gt;first(‘item’) }}@endif&lt;td&gt;&lt;/tr&gt;' ;
  
   $("table").append(row);
  
  }
  </code></pre>
  
  <p>I will call this method 5 times and it will create 5 input areas which name are item1. item2, item3, item4, item5.</p>
  
  <p>in server side ,I use Laravel 5.2 Form Request Validation to validate every input field. </p>
  
  <p>But if the validation failed , the old input and error will not set to the correct input field because </p>
  
  <p>I can’t put the javascript variable rowCount into  "{{ old(‘item') }}” which is a blade template.
  and the same is {{ $errors->first(‘item’) }}.</p>
  
  <p>I tried to write like this </p>
  
  <pre><code>'value="{{ old('giftValue[' . $rowCount .']') }}"&gt;'
  </code></pre>
  
  <p>and this</p>
  
  <pre><code>'value="{{ old('giftValue[' + $rowCount +’]’) }}"&gt;'
  </code></pre>
  
  <p>but does’t work.</p>
  
  <p>does anyone have a good idea to solve this problem ?</p>