I have a problem with the use of a specific button in the project. I'll explain: I have a window opened by the window.open command, so in this open window I have a button that takes the value of two input fields hidden in while in the database. When clicking on it, it has a function where it sends the value of this hidden field to another input of the page where the window.open is executed (for simplicity, the x.php page opens via window.open the page y.php, then on page y .php has a button that sends a value returned from the database to the input field in x.php).
Then the problem starts, when I click I can send one input to the other, only the first record listed in the database, the others do not send.
The part of y.php where it does this function follows:
These are the hidden fields:
$query = "SELECT * FROM equipamentos WHERE marker_id LIKE '$id'";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)){
<td>".$row['id']."</td>
<td>".$row['nome']."</td>
<td style=\"text-align:center;\">".$row['lat']."></td>
<td style=\"text-align:center;\">".$row['lng']."</td>
<td style=\"text-align:center;\">
<input type=\"hidden\" name=\"latMap\" id=\"latMap\" value ='".$row['lat'] ."'></input>
<input type=\"hidden\" name=\"lngMap\" id=\"lngMap\" value ='". $row['lng'] ."'></input>";
</td>
Then I have the submit button:
<button type=\"button\" id=\"btnLocalizar\" name=\"btnLocalizar\" class=\"btn btn-sm btn-primary\">
<i class=\"fas fa-map-marker-alt\"></i></button>
And the script to send:
<script>
var input1 = document.getElementById('latMap').value;
var input2 = document.getElementById('lngMap').value;
$(document).ready(function(){
$('#btnLocalizar').click(function(e){
e.preventDefault();
var input_value = $('#latMap').val();
$(window.opener.document)
.find('#latMap')
.val(input_value)
});
});
</script>
The only problem is just being able to send the first record, if anyone knows how to get all the records listed by the database query, it would be a great help.