简体   繁体   中英

how to call a modal from another php file when i click my link in my home page

How to call modal from another php file? Sorry I am just starting to learn wed development.

在此处输入图片说明

Considering this is a bootstrap modal (which it looks like it is), you can create a JavaScript function and echo it out in PHP. Something like this:

echo '<script type="text/javascript">',
 '$("#modal-id").modal("toggle")',
 '</script>';

The example above is form the Bootstrap 4 Docs where it demonstrates calling the modal from javascript. Once that script is echoed from your PHP, it'll run on the page and load the modal.

To Clarify: Even if this isn't a bootstrap modal, you can still use the same JavaScript technique to add/remove a class to the modal which you can style to make it show/hide.

The best way to do that is to create your modal in a separate Signup.php file then using php include function, include Signup.php inside Index.php eg <?php include('Signup.php'); ?> <?php include('Signup.php'); ?> . The php include function is used to call a page inside another page. Dont forget, index.php file, thats where you are to to place the link that to call Signup.php

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