Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
How do I pass a javascript variable coming from PHP object to javascript back to PHP to be used as an Index in Laravel?

I'm using Laravel 8 and creating a FullCalendar where when you click the event, more details can be seen via the modal that pops up.

events:[
    @foreach($events as $event)          
      { 
        id: '{{$loop->index}}', title: '{{$event->patientInfo->first_name}} - {{$event->patientTreatment->treatment}} - {{$event->patientService->service}}', 
        start: '{{$event->appointment}}', 
        resourceId: '{{$event->id}}', 
        color: '{{$event->branches->text_color}}', 
      },
    @endforeach
    ],

I'm retrieving the events Index from the id: '{{$loop->index}}'

eventClick: function(info) {
  var event_data = info.event.id;
},

I've checked it through alert(event_data); The alert verifies it's working thus far. Now I'm trying to get it so I can use it in PHP to get data and relational data beginning with this way

$event_data = $events[var_event_index_here];
$event_data->first_name; $event_data->phone;     
....etc

I have no idea how to use that javascript variable for the index. I've searched different ways of retrieving it, but this is what I've tried to test

eventClick: function(info) {

  var event_data = info.event.id;

  <?php
    $test= "<script>document.writeln(event_data);</script>";
  ?>

  var dialog =  '<div id="dialog" class="modalTitle"  style="z-index:9999">{{$test}}</div>';

  $('body').append(dialog);
  $('#dialog').dialog({modal:true, title: "TITLE"});
},

This is the result I'm getting

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda