good evening I have two sites the first in php and the second in wordpress
on the one in php i have a table with links
each link opens an article to wordpress
the link is in $donnees["guid"]
I did some var_dump of $donnees["guid"]
the results are correct
Except when the modal opens
It's always the same value
<div style="border: solid; text-align: center;"> <?php var_dump( $donnees['guid']); //is ok ?>
<button type="button" data-toggle="modal" onclick="openModal (event,'')"> Open modal </button>
<!-- The Modal -->
<div id="myModal">
<div >
<div >
<!-- Modal body -->
<div > Vous êtes sur le point d être redirigé pour visionner la sortie de pêche sur le nouveau site <?php var_dump( $donnees['guid']); ?> </div>
<div >
<div >
<h4 >Delete Confirmed</h4>
<button type="button" data-dismiss="modal">×</button>
</div>
<p>Il ce peux que la redirection prenne quelques secondes</p> <?php var_dump( $donnees['guid']);//is not ok ?> <div >
<button type="button" data-dismiss="modal" onclick="window.location.href = '
<?php echo ( $donnees['guid']); ?>', '_blank';">ok </button>
</div>
</div>
<!-- Modal footer -->
<div >
<button type="button" data-dismiss="modal">Close</button>
<button onclick="confirmDelete()">Ok on y va</button>
</div>
</div>
</div>
</div>
<!-- The Modal -->
</div>
function confirmDelete(){
console.log("Deleting...");
$('.modal-header, .modal-footer, .modal-body').addClass('hide');
$('.confirm-delete').removeClass('hide');
//$('#myModal').modal('hide');
}
function openModal(){
$('.confirm-delete').addClass('hide');
$('#myModal .modal-header, .modal-footer, .modal-body').removeClass('hide');
$('#myModal').modal('show');
}
CodePudding user response:
Make the different ids for different modals or make the template
When you have a few tags with id="myModal" it will open the first modal every time
html:
<button type="button" data-toggle="modal" onclick="openModal ('#myModal1')"> Open modal </button>
<!-- The Modal -->
<div id="myModal1">
js:
function openModal(eve, id){
$('.confirm-delete').addClass('hide');
$(id ' .modal-header, .modal-footer, .modal-body').removeClass('hide');
$(id).modal('show');
}
for next button it will be myModal2, myModal3 and etc.
Upd, for last changes:
html:
<button type="button" data-toggle="modal" onclick="openModal (event)"> Open modal </button>
<!-- The Modal -->
<div id="myModal1">
js:
function openModal(eve){
$('.confirm-delete').addClass('hide');
$(eve.target).next().modal('show');
$(eve.target).next().find('.modal-header, .modal-footer, .modal-body').removeClass('hide');
}