Reload page when HTML in <iframe src> changes

Discussion in 'HTML' started by P E Schoen, Mar 3, 2011.

  1. P E Schoen

    P E Schoen Guest

    I have a list of emails (in an HTML file) that are displayed on a page in an
    iframe. I also have text inputs for name, email, and a password, so that
    authorized users can add their emails. The emails are kept in an SQLite
    database and are accessed by a PHP script which checks authorization,
    disallows duplicates, and then echoes success or failure. If it succeeds, it
    updates the HTML email list in alphabetical order in the HTML file. When the
    user navigates back to the original form, I want the page to be refreshed so
    it shows the newly inserted email.

    There were several methods discussed on some websites I found, but most of
    them seemed rather complex. They often used a meta refresh, or something
    like this:

    window.location.reload();
    location.reload(true);
    location.href = location.href;
    history.go(0);

    http://irt.org/script/redirect.htm
    http://api.jquery.com/load/
    http://www.w3.org/QA/Tips/reback

    Here is what I did:

    <script type="text/javascript">
    function CheckModified() {
    if (Form1.Modified.value != "NO") {
    document.location.reload(true); // true = reload from server
    }
    }

    function SubmitEmail() {
    Form1.Modified.value = "YES";
    document.forms["Form1"].submit();
    }
    </script>

    <body onLoad = "CheckModified();">
    <form id="Form1" action="../cgi-bin/BGFemail2.php" method="POST">
    <input type="hidden" name = "Modified" value="NO">

    There is only one problem with this, as far as I can see. If the script
    fails, the reload is not needed, and in fact it clears the text input fields
    so they must be retyped if you want to try again.

    Is there a "better" way?

    This can be seen at:
    http://www.pauleschoen.com/bgf/BGFemail2.htm

    It will eventually be used on this website:
    www.baltimoregreenforum.org

    Thanks,

    Paul
    P E Schoen, Mar 3, 2011
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed "P E Schoen"
    <> writing in news:NsCbp.5682$:

    > I have a list of emails (in an HTML file) that are displayed on a page
    > in an iframe. I also have text inputs for name, email, and a password,
    > so that authorized users can add their emails. The emails are kept in
    > an SQLite database and are accessed by a PHP script which checks
    > authorization, disallows duplicates, and then echoes success or
    > failure. If it succeeds, it updates the HTML email list in
    > alphabetical order in the HTML file. When the user navigates back to
    > the original form, I want the page to be refreshed so it shows the
    > newly inserted email.
    >


    I would do something like:

    <?php
    'form processing stuff

    ?>

    <div id="emailist">
    <ul>
    <?php
    $sql = "SELECT email FROM table ORDER BY email";
    $rs = mysql_query($sql);
    while ($row = mysql_fetch_array($rs, MYSQL_NUM)){
    echo "<li>".trim($row[0])."</li>";

    }
    mysql_free_result($rs);
    ?>
    </ul>
    </div>
    <div id="inputform">
    <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
    <!-- rest of form -->
    </form>
    </div>

    I would set the emaillist div to float left, with a certain width, and
    overflow to scroll. If the form posts to itself, there is no need to use
    an iframe or client side script.

    Just a thought.
    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Mar 3, 2011
    #2
    1. Advertising

  3. P E Schoen

    P E Schoen Guest

    "Adrienne Boswell" wrote in message
    news:Xns9E9CC810E1116arbpenyahoocom@188.40.43.230...

    > I would do something like:


    > <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">


    > I would set the emaillist div to float left, with a certain width,
    > and overflow to scroll. If the form posts to itself, there is no
    > need to use an iframe or client side script.


    That might be a good idea, and it's certainly simpler. But I tried it and
    each time the form method is called, it advances the browser history, so the
    back button must be clicked for each email added, to return to the original
    page that invoked this email list. It's not a huge problem, but I think I'll
    stay with essentially what I have now, unless that can be fixed. Maybe use
    history(0)?

    Thanks,

    Paul
    P E Schoen, Mar 3, 2011
    #3
  4. Gazing into my crystal ball I observed "P E Schoen"
    <> writing in news:poFbp.44526$:

    > "Adrienne Boswell" wrote in message
    > news:Xns9E9CC810E1116arbpenyahoocom@188.40.43.230...
    >
    >> I would do something like:

    >
    >> <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];

    > ?>">
    >
    >> I would set the emaillist div to float left, with a certain width,
    >> and overflow to scroll. If the form posts to itself, there is no
    >> need to use an iframe or client side script.

    >
    > That might be a good idea, and it's certainly simpler. But I tried it
    > and each time the form method is called, it advances the browser
    > history, so the back button must be clicked for each email added, to
    > return to the original page that invoked this email list. It's not a
    > huge problem, but I think I'll stay with essentially what I have now,
    > unless that can be fixed. Maybe use history(0)?
    >
    > Thanks,
    >
    > Paul
    >
    >


    Do you want the user to be able to add more emails? If so, this should
    not be a problem. If you don't want them to be able to add more emails,
    just hide the div with the form, eg:

    <?php if(!$isposted){ ?>
    <div id="inputform">
    <!-- blah -->
    </div>
    <?php }?>
    <p><a href="otherpage.php">Go to other page</a></p>

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Mar 3, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ricardo

    Reload IFrame Src (VB)

    Ricardo, Feb 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,913
    Tampa.NET Koder
    Feb 19, 2005
  2. Ricardo

    Reload IFrame Src (VB)

    Ricardo, Feb 19, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    123
    Tampa.NET Koder
    Feb 19, 2005
  3. Soren Vejrum
    Replies:
    4
    Views:
    495
    Lasse Reichstein Nielsen
    Jul 5, 2003
  4. Alexandre Jaquet

    iframe.src reload ?

    Alexandre Jaquet, Apr 5, 2005, in forum: Javascript
    Replies:
    3
    Views:
    128
    Alexandre Jaquet
    Apr 6, 2005
  5. Shawn Witt
    Replies:
    1
    Views:
    78
    Shawn Witt
    Dec 19, 2005
Loading...

Share This Page