2
I’ve been trying to do a database search for a while, through an input. The idea is in a Model have an input to enter a date and without using a Submit send the date to another Model and then present the data already entered in the database in the other Model
So far I’ve only been able to show the date of the first Model in the 2nd, I also already have the "research" but it is commented.
HTML
<h2>Small Modal</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"
>Open Small Modal</button>
In the 1st Model
<div class="modal-body">
<input type="date" id="myDate" value="2000-05-05" style="font-size:20px;">
</div>
<div class="modal-footer">
<div class="teste3" data-toggle="modal" data-target="#myModal4" onclick="jstophp();teste50()">
<a class="collapse-item">Pesquisar</a>
</div>
In the 2nd Model
<input type="date" class="form-control form-control-user" id="dias" name="dia"
placeholder="Insira o Dia" style="margin-top:2%;margin-bottom:2%;font-size:20px;">
Javascript when Clicking on the 1st Model
<script>
function jstophp(){
javavar=document.getElementById("myDate").value;
document.getElementById("dias").value="<?php
$phpvar='"+javavar+"';
echo $phpvar;?>";
window.history.pushState( {} , '', '?data=<?php echo $phpvar ?>' );
<?php $batata = 50; ?>
<?php //$entradas = "SELECT * FROM calendario WHERE dia = '+javavar+' ";
//$resultado_entradas = mysqli_query($conn, $entradas);
//while($rows_calen = mysqli_fetch_array($resultado_entradas)){ ?>
//document.getElementById("teste<?php // echo $batata; ?>").innerHTML="batata";
<?php //$batata++; ?>
<?php //} ?>
}
</script>
I also tried through URL. I left down so much the attempt that I tried by URL and commented search.
if you don’t want to refresh the page, make a call
ajax
– Ricardo Pontual
Explain your question better. You want to open a modal that has an input send the input value to PHP and select in the database the data referring to that value and return the query to another modal on the same page that made the request?
– user60252