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

268
Visualizações
Can't direct into a route onclick with value with laravel

I have to add date value when i click hyperlink into my route, so i add like this:

<div class="card-body">
        <div class="form-group">
            <label>Tanggal Awal:</label>
            <input type="date" class="form-control" id="exampleInputPassword1" placeholder="Masukkan Tanggal Lahir" name="tglawal" id="tglawal">
        </div>
        <div class="form-group">
            <label>Tanggal Akhir:</label>
            <input type="date" class="form-control" id="exampleInputPassword1" placeholder="Masukkan Tanggal Lahir" name="tglakhir" id="tglakhir">
        </div>

          <a href="" onclick="location.href='/cetaklaporanpasien/'+document.getElementById('tglawal').value + '/' + document.getElementById('tglakhir').value " class="btn btn-block btn-primary border-0" style="background-color: #6998AB">Cetak</a>
    </div>

My Route:

    Route::get('/cetaklaporanpasien/{tglawal}/{tglakhir}', 'LaporanController@cetakLaporanPasien')->name('cetaklaporanpasien');

But it's doesn't directing into my route. So, how to add laravel route with parameter in onclick?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Try using <button> instead of <a>

So it will be like this:

<button type="button" onclick="(your link)">Button</button>
about 4 years ago · Juan Pablo Isaza Relatório

0

You should be considering to use blade template as it is laravel standart templating.

<div class="card-body">
    <div class="form-group">
        <label>Tanggal Awal:</label>
        <input type="date" class="form-control" id="exampleInputPassword1" placeholder="Masukkan Tanggal Lahir" name="tglawal" id="tglawal">
    </div>
    <div class="form-group">
        <label>Tanggal Akhir:</label>
        <input type="date" class="form-control" id="exampleInputPassword1" placeholder="Masukkan Tanggal Lahir" name="tglakhir" id="tglakhir">
    </div>

      <a href="" onclick="cetakLaporan" class="btn btn-block btn-primary border-0" style="background-color: #6998AB">Cetak</a>
</div>
<script>
  let tglawal = document.getElementById('tglawal').value;
  let tglakhir = document.getElementById('tglakhir').value;
  function cetakLaporan(){
   location.href = `/cetaklaporanpasien/${tglawal}/${tglakhir}` 
  }
</script>
about 4 years ago · Juan Pablo Isaza Relatório
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