SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member Victor's Avatar
    Join Date
    Dec 2000
    Location
    Georgia
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript to detect page changes...

    I have a form and would like to pop-up a JavaScript alert reminding the user to click on
    "save/update" before clicking on any other link/moving to the next page. The alert isn't
    necessary if no changes were made on the page. Is this possible?

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    add onChange="setVar()" to all of your form elements, and onClick="return checkVar()" to all of your links.
    Code:
    <script>
    <!--
    changed = false;
    function setVar(){
      changed = true;
    }
    
    function checkVar(){
      if (changed) {
      alert("You need to save your data!");
      return false;
      }
      return true;
    }
    //-->
    </script>


Bookmarks

Posting Permissions

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