0

I am using laravel and I got this error. What I want to achieve is getting coordinator id and display it to input coordinatorname. I am using for loop to get the data but it gives error about constant 'i'. Does anyone know how to fix this?

This is my Javascript code:

function defaultcoor(course)
 {
  for(let i=0; i < {{ count($codes) }}; i++)
   {
       for(let j=0;j < {{ count($coordinators) }}; j++)
       {
          if(course ==  {{ $codes[i]->id }}  &&  {{ $coordinators[j]->staffid }} == {{ $codes[i]->coordinator_id }})
          {
            document.getElementById("coordinatorname").value = $coordinators[j]->id;
          }
       }
   }
 }
  • 2
    You are mixing the js and laravel code. Either use full js or laravel code whatever you want to archive. – Apurv Bhavsar Dec 01 '21 at 10:26
  • @T.J.Crowder I deleted my comment because it wasn't precise enough. You are obviously right with your statement. Since default Laravel is based on PHP and using the MVC framework I assumed that my statement was good enough. In hindsight I should have wrote that in this case PHP is used on the server as the server side language and that JS is used on the client side as the client-side language. Nevertheless, thank you for reminding me to choose my words more careful. – Aless55 Dec 01 '21 at 10:39

0 Answers0