PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jul 23, 2017 1:36 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu May 18, 2017 6:11 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
https://www.w3schools.com/howto/howto_css_modals.asp
Found this, and is really smart. Responsive too. Trouble is, it seems to only work for one modal pop up per page.

Can it be adapted to do multiple?

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 8:39 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
Multiple how? The simplest tactic would be to make the modal be a container, then show and hide the elements within as needed.

As in
Syntax: [ Download ] [ Hide ]
<div id="modal">
        <div id="modal1">Modal 1</div>
        <div id="modal2">Modal 2</div>
</div>

Syntax: [ Download ] [ Hide ]
var $modal = $("#modal");
function showmodal(child) {
        $modal.children().hide();
        $modal.children(child).show();
        $modal.show();
}

function hidemodal() {
        $modal.hide();
}

Syntax: [ Download ] [ Hide ]
showmodal("#modal2");


Multiple actual modal dialogs is also possible, of course. Basically you use classes instead of IDs for the CSS, show one modal by hiding the others (by class) and showing the one you want (by ID), hide the modal by simply hiding all of them; hiding all at once saves you having to track which is open.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group