I have the following code
echo "<td class = container_update ><a href = 'ShowAngajati.php?id=$row[ID_Angajati]
&nm=$row[Nume]
&pr=$row[Prenume]
&cn=$row[CNP]
&dn=$row[Data_Nasterii]
&se=$row[Sex]
&nr=$row[Numar_Telefon]
&sa=$row[Salariu]
' id='myBtn'>Update</a></td>";
and the script
<script>
// Get the modal
var modal = document.getElementById("myModal");
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
Thing is I want a modal to pop up when i click on the link ("Update"). It does pop up but only for a second (while the tab is refreshing) and it pops up only when i click on the first row of my table. The conlusion would be: I'd have a big table (for a database) with a "update" button on each row that when i click would pop out a modal with an already completed form (completed with the data already in my database) and just change the thing i want to change (that's why i need the nm, pr, cn and so on variables).