最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to call bootstrap modal in php - Stack Overflow

programmeradmin0浏览0评论

I'm trying to call a modal that I have in a html file which is hidden alongside another modal. One of them appears as the button is clicked but the other one is to be called by php as part of a verification process.

Here is my php code:

$File = include("index2.html");
$Msg = 'Wele ';
$search=$_POST['search'];
$query = $pdo->prepare("SELECT * FROM students WHERE IDs LIKE '%$search%'  LIMIT 0 , 10"); //OR author LIKE '%$search%'
$query->bindValue(1, "%$search%", PDO::PARAM_STR);
$query->execute();
// Display search result
         if (!$query->rowCount() == 0) {
                 echo '<script type="text/javascript">';
                                 echo 'alert("Verification Complete");';
                                  echo '</script>';



            while ($results = $query->fetch()) {

                $Studname = $results['Studentname'];


                echo '<script type="text/javascript">';                
                echo 'alert("'.$Msg.$Studname.'")';
                echo '</script>';



               echo '<script type="text/javascript">';
               echo '$(File).ready(function() {';
               echo '$("#myAdvert").modal("show");';
               echo '});';
               echo '</script>';

            }

         } else {
           echo '<script language="javascript">';
            echo 'alert("Sorry your ID was not found");';
            echo 'window.location.href = "/Koleesy/index.html";';
            echo '</script>';
        }
?>

After the user is weled I want the hidden modal from my index.html to be called so the user can continue submitting the advert. I've tried using the include function but that doesn't seem to work in my favor. How do I do this? Every answer is appreciated.

I'm trying to call a modal that I have in a html file which is hidden alongside another modal. One of them appears as the button is clicked but the other one is to be called by php as part of a verification process.

Here is my php code:

$File = include("index2.html");
$Msg = 'Wele ';
$search=$_POST['search'];
$query = $pdo->prepare("SELECT * FROM students WHERE IDs LIKE '%$search%'  LIMIT 0 , 10"); //OR author LIKE '%$search%'
$query->bindValue(1, "%$search%", PDO::PARAM_STR);
$query->execute();
// Display search result
         if (!$query->rowCount() == 0) {
                 echo '<script type="text/javascript">';
                                 echo 'alert("Verification Complete");';
                                  echo '</script>';



            while ($results = $query->fetch()) {

                $Studname = $results['Studentname'];


                echo '<script type="text/javascript">';                
                echo 'alert("'.$Msg.$Studname.'")';
                echo '</script>';



               echo '<script type="text/javascript">';
               echo '$(File).ready(function() {';
               echo '$("#myAdvert").modal("show");';
               echo '});';
               echo '</script>';

            }

         } else {
           echo '<script language="javascript">';
            echo 'alert("Sorry your ID was not found");';
            echo 'window.location.href = "/Koleesy/index.html";';
            echo '</script>';
        }
?>

After the user is weled I want the hidden modal from my index.html to be called so the user can continue submitting the advert. I've tried using the include function but that doesn't seem to work in my favor. How do I do this? Every answer is appreciated.

Share Improve this question asked Oct 28, 2015 at 11:14 KamandaKamanda 3053 gold badges5 silver badges11 bronze badges 4
  • Where is your modal box defined? – Happy Coding Commented Oct 28, 2015 at 11:17
  • It's in my main index file, on the home page. I named that index2 because the php couldn't find the main one so I duplicated it and threw the index2 into the folder with the php. – Kamanda Commented Oct 28, 2015 at 11:20
  • Just a suggestion, instead of writing lots of echo statements you can do something like <?php if(true){?> <div>your html code goes here</div> <?php } ?> this would make your code more readable. – Arpita Commented Oct 28, 2015 at 11:57
  • Thanks for the advice, i'll definitely use that. Its quite messy with all the echos – Kamanda Commented Oct 28, 2015 at 12:02
Add a ment  | 

1 Answer 1

Reset to default 6

Try this:

echo "<script type='text/javascript'>
$(document).ready(function(){
$('#myAdvert').modal('show');
});
</script>";
发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>