简体   繁体   中英

How do I pass the variable data from PHP While Loop to Bootstrap Modal?

I'm beyond frustrated. Your help is greatly appreciated!

So this website code has a PHP while loop that has unordered list items inside of it.

How can I modify this code below to get it to work for each person to have their own modal with their different information inside? (This code below is the link above)

Note: I tried taking the modal outside the while loop and only put the PHP variables and echo statements for data-target and id . But, as you imagined it didn't work outside the while loop.

Thank you!

This is a javascript problem, not a wordpress loop one. Move the modal out of the loop, this is first. Second, the data of each person can be saved in any div or in the button that opens the modal in each case, it will be easy, in there you add some data-whatever attributes, ie. data-descripcion, data-title. When the button is clicked, you can pull the data from the button itself and replace the .modal-title y .modal-body with the correct info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM