2
Well, I made an extract that selects the DB data and prints them on the screen through while, which is generating the correct values, but now I’m trying to create an edit button that opens a popup with inputs already filled with values, but this form is only receiving the values of the 1st loop. Does anyone have any suggestions to solve the problem?
Follow the code I’m trying to fix:
while($linha=$buscarextrato->fetch(PDO::FETCH_ASSOC)){
echo '
<div class="div" style="border:0px;width:80px;">
<div data-role="popup" id="Popup" class="ui-content" style="min-width:500px;">
<form style="display:inline;" name="lanc" action="editalanc.php" method="POST" enctype="multipart/form-data" >
<input type="hidden" name="numlanc" value="'.$linha[lancamento].'"/>
<input type="date" name="data" value="'.$linha[data].'"/>
<input type="number" name="debito" value="'.$linha[debito].'"/>
<input type="number" name="credito" value="'.$linha[credito].'"/>
<input type="number" name="valor" value="'.$linha[valor].'"/>
<input type="text" name="descricao" value="'.$linha[descricao].'"/>
</form>
</div>
<a href="#Popup" data-rel="popup"><i class="material-icons">mode_edit</i></a>
</div>
';
JS code obtained by reference:
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
CSS:
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
OBS: The generated values (line) vary correctly in each loop, the only thing that does not change is the form, it seems to me that it receives the value of 1 loop and ignores the rest.
Probably your error is in Javascript, trying to open the popup through id
#Popup
. Like the attributeid
defines a unique DOM element, it will always be the first form. You will need to change this to fix the problem, either generatingids
unique to each form, whether changing the way of referencing it.– Woss
in case I am using jquery, I have no idea how to modify the code, I must change the way to do it then?
– Wel
Yes, but first edit your question and add your JS code that deals with the popup.
– Woss
the source is in the links I posted above.
– Wel