1
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 which is in while in the database. When you click on it, it has a function where it sends the value of this Hidden field to another input from the page on which the window runs.open (To simplify, the x.php page opens via window.open to the y.php page, so on the y.php page there is a button that sends a value returned from the database to the input field in x.php).
Then the problem begins, when I click I can even send from one input to the other, only only the first listed record of the database, the others do not send.
Follow the part of y.php where you do this function:
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>
So I have the send 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 only to be able to send the first record, if someone knows how to get all the records listed by the database query, it would be of great help.
In y.php you have a while and you want to send all the input Hidden #latMap to an input on the x.php page? All in one input on the x.php page only?
– Sam
So I have two input fields on page x, and I have two Hidden input on page y, only this Hidden input only sends the value of the first listed query record. I wanted when I clicked on the button of the second record (eg record 1 - brntwp; record 2 - dvd) it replaced the value that was in that input field there of x, and as I would click on the buttons next to the records, I would swap there in the two inputs of x
– brnTwp