0
Using the bootstrap documentation,
made a change of a href
for button
<button type="button" class="btn-a" data-toggle="modal" data-target="#EditaFoto"
data-whatever="<?php echo $row['idfoto']; ?>"
data-whateverdatavisita="<?php echo $row['datavisita']; ?>"
data-whateveridvisita="<?php $row['idvisita']; ?>"
data-whateverpercetandamento="<?php $row['percentandamento']; ?>"
data-whatevercaminhofoto="<?php $row['caminhofoto']; ?>"
data-whateverdescricaofoto="<?php $row['descricaofoto']; ?>"
>
<i class="fas fa-edit"></i>
When you click the button it loads the information and sends it to Modal.
In the JS:
$('#EditaFoto').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever') // Extract info from data-* attributes
var recipientdatavisita = button.data('whateverdatavisita')
var recipientidvisita = button.data('whateveridvisita')
var recipientpercetandamento = button.data('whateverpercetandamento')
var recipientcaminhofoto = button.data('whatevercaminhofoto')
var recipientdescricaofoto = button.data('whateverdescricaofoto')
var modal = $(this)
modal.find('.modal-title').text('ID Foto ' + recipient)
modal.find('#datavisita').val(recipientdatavisita)
modal.find('#idvisita').val(recipientidvisita)
modal.find('#percentandamento').val(recipientpercetandamento)
modal.find('#caminhofoto').val(recipientcaminhofoto)
modal.find('#descricaofoto').val(recipientdescricaofoto)
})
Only in case it’s only working these two parts:
data-whatever="<?php echo $row['idfoto']; ?>"
data-whateverdatavisita="<?php echo $row['datavisita']; ?>"
The rest aren’t loaded. In PHP everything is right and the data is coming feed the variables.
first that the link does not have an id to be referenced.
$("EditaFoto")
you need to start with#
, thus:$("#EditaFoto")
otherwise it will search for a tag called "Editafoto" (ie<EditaFoto> </EditaFoto>
)– Máttheus Spoo
So how else can I pass this id? the id I get with
<?php print($row['idf']); ?>
I just don’t know how to get past this to Modal and load the data.– JB_
Then you put only the link you click to open the modal, the data is presented in a table? Note that this answer does not help you: https://answall.com/questions/239981/
– Laércio Lopes
I made a modification here in the code, but it is not loading all the data. I edited the question.
– JB_