Domanda

I am interested in displaying an alert to a user with OK button to close the alert, and a more/details button which upon clicking on it displays certain details (text, table, data, etc). Can it be done using PHP/HTML alone?

È stato utile?

Soluzione

The situation you're describing is possible, but would not be the accepted or fastest way of doing it. Using PHP requires a trip back to the server which reloads the page - not something you want to be doing if you want easy usability.

The recommended solution is to use Javascript, or jQuery. I would recommend against using jQuery UI unless you're going to use more than one part of it - it's a great library but it has much more functionality than you need and unless you host the file yourself, the download you get from major CDNs is large and will take a while to load.

However, there is a solution I know of and have use called Alertify. It is a JS plugin that deals specifically with alert, confirm and prompt dialog boxes, and can be fully customised. Here's the site if you want to have a look: https://fabien-d.github.io/alertify.js/. It comes with demos and example code so you can adapt that to your purposes.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top