Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

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

Here's what I've got:

User generated image
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
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

I was looking at the wrong link, Julian! I had three to choose from and I went with the wrong one.

You're right!

Thanks!
You are welcome Bruce