how can i pass php variables to my modal box.
I have my modal box made with css and my query in php is with while this prints me a series of consecutive data, so I also have a button inside that while that says info. The idea is to be able to press the info button and at least take the record id to the modal box:
This is my query:
<table class="table">
<thead>
<tr>
<th scope="col">POSICIÓN</th>
<th scope="col">TRABAJO A REALIZAR</th>
<th scope="col">HORA SALIDA</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php
$iniciado=mysqli_query($conn,"select * from `p_atendidas` where refe='$elid'");
while($posreal = mysqli_fetch_array($iniciado)){
?>
<tr>
<th scope="row">
<select class="camptwo" required>
<option><?php echo $posreal['posatendi']?></option>
</select></th>
<td style="font-size:12px;">
<select class="camptwo" required>
<option><?php echo $posreal['tipotrabajo']?></option>
</select></td>
<td><input type='time' class='camptwo' style='width:140px;' name='horafinal[]' required ></td>
<td><a href="#openModal?id_patendi=<?php echo $posreal['id_patendi']?>" class="md-close">info</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
And this is my modal box with HTML and CSS
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<?php $id_patendi=$_GET['id_patendi']; ?>
<input type='text' name='id_patendi' value="<?php echo $id_patendi?>">
</div>
</div>
Currently my modal box works if I click the info button inside the while, but to pass the variable the way I do it doesn't work. what could i do in that case? everything is on the same screen.
I don't know if it can be done with javascript.
Greetings and thank you very much for any help you can give me.
Set a custom attribute to your anchor, when displaying your modal you load the data by javascript and assign it to the value of the input.