0
good evening everyone,
I’m doing a job at my college and I’m having a hard time at one part. I’ve researched and tried several ways, as I’m starting maybe there’s another way that I don’t know.
I have two pages index.php and localize.php, I need to send the variable id_pet to the page locate, this I did using get by the link URL so far I managed to do quiet ta working. But I also need to send the initial and final date on a form. I wanted to do this using the same button as I use to send id_pet. As my upload button is outside the form I used Jquery to submit the form and it worked using this code since the input type Submit is outside the tag "a" so it submits the form. Below is the jquery code:
$(document).ready(function(){
$(".btnLocalizar").click(function(){
$("#formData").submit();
});
});
but as I want to send everything with a button I tried to do the following:
while($row = mysqli_fetch_array($resultado)){
echo "<tr>";
echo "<td>" . $row["id_pet"]."</td>";
echo "<td>" . $row["nome_pet"]."</td>";
echo "<td>" . $row["nome_tutor"]."</td>";
echo "<td>" . "<a href='localizar.php?id_pet=$row[id_pet]'>";
echo "<input class='btn btn-primary btnLocalizar' type='submit' value='Localizar'>";
echo "</a>";
echo "</td>";
}
This php code generates my table with the result of my mysql test database and already includes in the table the link/Submit that sends the id_pet variable to the page I need. But when this way I click on the button and it sends only the php variable and does not submit my page form using the javascript code from above.
Only I didn’t understand, if I create an input of type Submit outside the tag "a" the code Jquery works normal and submits the form, but then I have no way to send the php variable.
I hope it was clear my doubt, I need to send the form data and the php variable using a single Submit or link if and what to do this.
from now on thanks
Where the input is outside the form
– adventistaam
Because it is inside a Voce form to add the variable in an Hidden input: eg:
<input type='hidden' value='<?php echo $id_pet ?>' name='id_ped'>
– adventistaam
Or Voce wants to send all table data?
– adventistaam
when you keep the input inside the "a" tag and try to give a Ubmit, some error appears in the console?
– Gabriel José de Oliveira
this one and the input line:
echo "<input class='btn btn-primary btnLocalizar' type='submit' value='Localizar'>";
i need to send my mysql table only id_Pet, but I wanted to send together the contents of my form that is before this line of Submit– sarge88