troubleshooting Question

How can I open up the parent window from a Bootstrap modal?

Avatar of Bruce Gust
Bruce GustFlag for United States of America asked on
jQueryBootstrap
3 Comments1 Solution8 ViewsLast Modified:
Here's what I've got:


You enter some search criteria, you get this window and we're looking good!

What I want to do, however, is alluding me.

I want my user to click on the "Basic Setup" result and have that page open up in the "parent" window rather than a new page entirely.

How?

Here's the modal box and the JQuery that's facilitating the form:

<script>
   $('#searchBox').click(function(event) {
      event.preventDefault();
      
      var out = {
         'searchCriteria': $('#search_criteria').val()
      };
      $.post('search.php', out, 
      function(data) {         
      $('.modal-body').html(data);
         $(searchBoxModal).modal('show');
      });
      
   });
</script>

<div class="modal fade in" id="searchBoxModal" role="dialog" aria-labelledby="searchBoxTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
   <div class="modal-content">
     <div class="modal-header">
      <h5 class="modal-title" id="searchBoxLongTitle">Search Results...</h5>
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
     </div>
     <div class="modal-body">
      
     </div>
     <div class="modal-footer">
      <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
     </div>
   </div>
  </div>
</div>   

Open in new window


This is the HTML being passed back into the modal after a successful search:

<div class="row">
   <div class="col-xs-12" style="border:1px solid #ccc; box-shadow:5px 5px 3px #ccc; border-radius:10pt; padding:10px; width:85%; margin:auto;">
      <table class="table">
      <?php   
      $search = trim($_POST['searchCriteria']);
      $querystate = "SELECT * from pages where body LIKE '%$search%' order by page_name";
      $resultstate = mysqli_query($cxn, $querystate)
      or die ("Couldn't execute query.");
      while ($row=mysqli_fetch_assoc($resultstate))
      {
      ?>
         <tr>
            <td style="width:75%;"><a href="../page.php?ID=<?php echo $row['id'];?>" target="_blank"><?php echo stripslashes($row['page_name']);?></a></td>
            <td style="text-align:center; width:">
               <div style="background-color:#ccc; border-radius:15px; margin:auto; width:82px; padding:5px; height:27px; border:1px solid #b7b6b6; box-shadow:3px 3px 1px #818080;">
                  <div style="border-radius:10px; margin:auto; text-align:center; width:72px; height:20px; margin-top:-2px; margin-left:-1px; background-color:#fff; 
                  box-shadow:2px 2px 1px #606060 inset;">
                     <A HREF="page_display.php?ID=<?php echo $row['id']; ?>&Edit=Yes" style="font-size:10pt; text-decoration:none; color:#000; font-weight:bold;" >edit</a>
                  </div>
               </div>
            </td>
            <td style="text-align:center;">
               <div style="background-color:#ccc; border-radius:15px; margin:auto; width:82px; padding:5px; height:27px; border:1px solid #b7b6b6; box-shadow:3px 3px 1px #818080;">
                  <div style="border-radius:10px; margin:auto; text-align:center; width:72px; height:20px; margin-top:-2px; margin-left:-1px; background-color:#fff; 
                  box-shadow:2px 2px 1px #606060 inset;">
                     <A HREF="page_display.php?ID=<?php echo $row['id']; ?>&Edit=No" style="font-size:10pt; text-decoration:none; color:#000; font-weight:bold;" >delete</a>
                  </div>
               </div>
            </td>
         </tr>
      <?php 
      }
      ?>
      </table>
   </div>
</div>

Open in new window

How do I code things in such a way where the user would click on a search result and the new page will open up in the parent window?
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 3 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 3 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004