1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to stop reloading the page while clicking form submit in php

Discussion in 'PHP' started by vishalrao84, Aug 12, 2014.

  1. #1
    Hi Friends,

    Can some one please help me in telling how to stop relaoding of the page while clicking form submit.

    Regards,
    Vishal
     
    vishalrao84, Aug 12, 2014 IP
  2. shemseddine

    shemseddine Active Member

    Messages:
    144
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    55
    #2
    you would want to check if the submit button has been pressed and if it has you need to check the beforeunload and return false to stop it.

    
    /* Check if button has been clicked first */
    
    window.onbeforeunload = function (e) {
        var e = e || window.event;
    
        // For IE and Firefox
        if (e) {
            e.returnValue = 'Leaving the page';
        }
    
        // For Safari
        return 'Leaving the page';
    };
    Code (markup):
    //Got the code from a stackoverload answer but the principles are the same
     
    shemseddine, Aug 12, 2014 IP
  3. abhicyco

    abhicyco Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #3
    You can use ajax functionality...

    Page wont reload and form would also be posted.
     
    abhicyco, Aug 21, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Might I ask why you even consider it an issue in the first place? Or do you have some fat bloated train wreck of how not to build a website where there's so much garbage in the markup it takes forever?
     
    deathshadow, Aug 21, 2014 IP