how to go to previsous page and do function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krista

    #1

    how to go to previsous page and do function

    Hi guys,

    i don't know how to write when i click a submit button, i can do a
    function and go back to previous page.

    eg, when i click "No" button, the system will do deletefunction( ), and
    go back to previous page. I only know if the button is
    <input type =\"button\" name=\"submit\" value=\"No\"
    OnClick=\"JavaS cript:history.g o(-1)\" ><br> i can go to previous page.
    But how can i do deletefunction( )??
    thx

    krista
  • Pedro Graca

    #2
    Re: how to go to previsous page and do function

    Krista wrote:[color=blue]
    > eg, when i click "No" button, the system will do deletefunction( ), and
    > go back to previous page. I only know if the button is
    ><input type =\"button\" name=\"submit\" value=\"No\"
    > OnClick=\"JavaS cript:history.g o(-1)\" ><br> i can go to previous page.
    > But how can i do deletefunction( )??[/color]

    Going back with JavaScript does not submit to the server (I think), and
    therefore you can't execute anything.

    Instead make that a normal submit button and process it with php,
    calling deletefunction( ) and redirecting to some page on your site:

    <input type="submit" name="submit" value="No"/>

    and your PHP script

    <?php
    // ...
    if ($_POST['submit'] == 'No') {
    deletefunction( );
    $redir = 'http://www.yoursite.co m/index.html';
    header('Locatio n: ' . $redir);
    // some browsers may not follow the redirect
    exit("Redirecte d: <a href=\"$redir\" >$redir</a>.");
    }
    // ...
    ?>
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    Working...