Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:57:33+00:00 2026-06-04T14:57:33+00:00

I have a simple application here (QandATable2.php) where when the user clicks on the

  • 0

I have a simple application here (QandATable2.php) where when the user clicks on the plus button, it will open a modal window and it displays the details which is stored in another page (previousquestions.php).

Now the problem I have is that if you straight away click on the “Search” button when the textbox is blank, you will see that it loads the page on its own page, displaying the details on that page. This is incorrect.

What I want it to do is that if the user has clicked on the search button, then I want the details to be stored within the modal window, not on its own whole page. I have heard that the best solution to use is by using an iframe. So does anyone know how this can be acheived using an iframe?

The modal window I am using is known as SimpleModal and it’s website is here

Below is the QandATable2.php code where it displays the plus button and where it opens the modal window, linking the content of the modal window to the previousquestions.php page:

<script type="text/javascript">          
    function plusbutton() { 
        // Display an external page using an iframe 
        var src = "previousquestions.php"; 
        $.modal('<iframe src="' + src + '" height="100%" width="100%" style="border:0">');
        return false;
    }   
    function closewindow() {     
        $.modal.close(); 
        return false;
    }         
</script>

<h1>CREATING QUESTIONS AND ANSWERS</h1>
<table id="plus" align="center">
    <tr>
        <th>
            <a onclick="return plusbutton();">
                <img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage"/>
            </a>
            <span id="plussignmsg">(Click Plus Sign to look <br/> up Previous Questions)</span>
        </th>
    </tr>
</table>

Below is the previousquestions.php code, where it displays the details in the modal window and where the search feature is stored:

<?php
    foreach (array('questioncontent') as $varname) {
        $questioncontent = (isset($_POST[$varname])) ? $_POST[$varname] : '';
    }
?>

<div id="previouslink">
    <button type="button" id="close" onclick="return closewindow();">Close</button>
    <h1>PREVIOUS QUESTIONS</h1>

    <p>Search for a previous question by entering in a phrase in the search box below and submitting the phrase</p>

    <form action="previousquestions.php" method="post">
          <p>Search: <input type="text" name="questioncontent" value="<?php echo $questioncontent; ?>" /></p>
          <p><input id="searchquestion" name="searchQuestion" type="submit" value="Search" /></p>
    </form>
</div>

<?php 
    //...connected to DB
    if (isset($_POST['searchQuestion'])) {
        $questionquery = "SELECT QuestionContent FROM Question
              WHERE(QuestionContent = '".mysql_real_escape_string($questioncontent)."')";
        if (empty($questioncontent)){
            echo "Please enter in a phrase in the text box in able to search for a question";
        }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:57:34+00:00Added an answer on June 4, 2026 at 2:57 pm

    Taken from the examples:

    // Display an external page using an iframe
    var src = "http://365.ericmmartin.com/";
    $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
        closeHTML:"",
        containerCss:{
            backgroundColor:"#fff",
            borderColor:"#fff",
            height:450,
            padding:0,
            width:830
        },
        overlayClose:true
    });
    

    To suit your needs:

    function plusbutton() {
        // Display an external page using an iframe
        var src = "previousquestions.php";
        $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
            closeHTML:"",
            containerCss:{
                backgroundColor:"#fff",
                borderColor:"#fff",
                height:450,
                padding:0,
                width:830
            },
            overlayClose:true
        });
    }
    

    And let the form do its job as usual (no event handler here) or if that does not work, try adding target="_self" in the form’s attributes, this ensures that the page opens inside the iframe.

    Otherwise, instead of iframes, I would suggest using ajax and load them inside a normal div then, but it’s up to you.

    UPDATE: To answer your questions in the comments:

    Problem 1: The modal box is set to 100% hieght and 50% width so I set
    the iframe to same, now width is perfect but hieght of iframe doesn’t
    go down to 100%.

    Try style="width:100%;height:100%;" instead of width="100%" height="100%" (I think it does not work to put percentage values in these attributes)

    UPDATE 2: It seems the problem is not here, but with the .simplemodel-data class that contains the iframe, a “hacky” solution is to add to your css: .somplemodel-data {height: 100%;}. Check the docs to see if there is something “official” about that.

    Problem 2: I have a close button where if the user clicks on the
    “close” button, it closes the modal window, but now it doesn’t close
    the modal window, it keeps stating it is undefined.

    The close button will not work, because the closewindow function is defined in the parent window while you are calling it from inside the iframe. To overcome this you have 2 solutions:
    1. either you put the close button outside the iframe and keep the rest as it is
    2. or you call the parent window’s closewindow function.

    For 1: $.modal('<button type="button" id="close" onclick="return closewindow();">Close</button><iframe src="' + src + '" style="border:0;width:100%;height:100%;">'); in “QandATable.php”

    For 2: <button type="button" id="close" onclick="return parent.closewindow();">Close</button> in “previousquestions.php” (or maybe replace parent by top, I think it’s the same)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple application where a user clicks on an area, and the
I have a simple application with just a window and a user control. The
enter code here Hi All, I have a simple windows service application that connects
I have a simple application in which I need to let the user select
I have a simple application written in C# and .Net 2.0 that displays several
I am using PHP and Smarty. I have a simple application that: Shows page
I am looking for some general feedback here. I have a very simple application
I have a simple Qt application that launches a window with a QWebView. I
I have a simple application that has a single page with a button that
I have a simple application that views comics and allows the user to mark

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.