Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Making the webpage refresh on submit...

    Hi

    I have this code in a file that is displayed in an inframe:

    <CENTER>
    <FORM action="index.php?step=2&amp;Count=<? $submitCount = $TotalCount + 50; print($submitCount); ?>" method=post><B>In Remembrance of:</B><BR><INPUT name=nume><BR>&nbsp;<INPUT type=submit value="Light a Candle" name=submit></CENTER></FORM></TD></TR></TABLE></SCRIPT></TD></TR></TABLE></CENTER>
    <DIV></DIV>

    What would I need to add to get it to refresh a specific webapge when a user clicks submit?

    Kind regards

    Antony

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    To refresh which specific webapge ? All the page inside which IFRAME is located ?

    1) You could refresh the topmost page with JavaScript (provided JavaScript is turned on in the user browser) by adding (I did not check it but I think it could give you an idea ... )

    onsubmit="top.location.reload(true); return true;"

    to the form tag.

    2) Or you could add the attribute
    target="_top"
    to your form tag, but in this case the form would be submitted to the top page, not to the IFRAME. And you would need to transfer the necessary data to the IFRAME src via e.g. GET (you get the parameters to transfer at the top page and form the src attribute value of IFRAME with query string including all the parameters you need to transfer to IFRAME - probably would not be good if you need to transfer too much data).

    I think there could be other methods ...

  • #3
    New Coder
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi

    Thank you for yur reply, Could I just refresh a specific page? for example http://mydomain.com/mayfiles/index.php ?

    Basically my form adds the info inputted to a mysql database, then another file displays the info from the database.

    When the users submits the info, they have to manually refresh the page to complete the input and display what they have written in the form.

    I am trying to code the form so it refreshes the page automatically once they click submit.

    Also I added the codes that SKDevelopment suggested but they stopped the form from working.

    Thanks

    Antony

    Kind regards

    Antony
    Last edited by tonyjms2005; 09-15-2009 at 07:11 PM.

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Try to add to the top page (the page which must be refreshed) the following script:
    Code:
    <script language="javascript" type="text/javascript">
    function page_reload(){
     window.location.reload(true);
     return true;
    }
    </script>
    And to the form in iframe add the attribute:
    onsubmit="return top.page_reload();"

    I think it would work. At least if JavaScript in the user browser is turned on.

    Also, if you need to refresh the whole page (not only the iframe area) on form submit, why are you using the iframe at all ? Without the iframe the whole page would reload naturally on the form submit ...

  • #5
    New Coder
    Join Date
    Oct 2008
    Posts
    42
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi
    Any change that is made to any of the form code seems to stop it from adding anything to the database.

    As this is the case, could I look at the index.php file? as this is the form action as shown in the code.

    Here is some of the index.php code:
    //Select DB
    MySQL_select_db(DATABASE_NAME) or die(MySQL_error());
    $nume = $_POST['nume'];
    ?>
    <?

    $nume = htmlentities($nume);
    if($nume != "")
    {
    $Query3 = "SELECT ID FROM candle WHERE Name=\"$nume\"";
    $DatabaseResult3 = MySQL_query($Query3, $DatabaseLink);
    if(!($DatabaseRow = MySQL_num_rows($DatabaseResult3)))
    {

    mysql_query("INSERT INTO candle(Name) VALUES(\"$nume\") ") or die(mysql_error());
    }
    }

    ?>
    <?
    $Query = "SELECT max(ID) AS Count FROM candle";
    $DatabaseResult = MySQL_query($Query, $DatabaseLink);
    $DatabaseRow = MySQL_fetch_object($DatabaseResult);
    if ($DatabaseRow->Count>0) ?>


    Here is the part which I think is to do with the form:

    ?
    print($TotalCount);
    if(!isset($preCount))
    {
    $preCount = $TotalCount - 10000;
    }
    if(!isset($Count))
    {
    $Count = $TotalCount + 10000;
    }

    ?>

    <?
    if($submit == "Search" || $yes == "yes")
    {
    print("");
    print("Search Result: ");
    $Query = "SELECT ID, Name FROM candle WHERE Name LIKE \"%$search%\" ORDER BY ID DESC";
    $DatabaseResult = MySQL_query($Query, $DatabaseLink);
    while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
    {
    $id = $DatabaseRow->ID + 5;
    print("<a href=\"index.php?Count=$id\">$DatabaseRow->Name</a>");
    }

    if(MySQL_num_rows($DatabaseResult) == 0)
    {
    print("None found.");
    print("<a href=\"index.php?Count=$TotalCount\"></a>");
    }
    }else
    {

    ?>

    Could doing something with this file be the key?

    I use an imframe because the form and index file used to be one file but I split it to show the index file in a scroller and keeping the form stationary and using iframes is the only way it will work.

    Thanks

    Antony


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •