confirmation box when an event occurred in form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarvanhsr
    New Member
    • Jan 2010
    • 8

    confirmation box when an event occurred in form

    I want confirmation box when i press link "Are you sure want to navigate.. The Entered data will not be saved"... and the condition is ... when form content is not changed i dont want confirm box.(simply.. i want to check the event occurred in form... if it occurs confirm box...else...na vigate...)I am having lot of textbox, checkbox, dropdown in my form.. so i unable to do this.. please help..as soon as possible....

    Thanks in advance...

    Code:
    function modal(name,id)
    	{
    		var con =  confirm("The data will not be saved..Are you sure want to proceed!");
    		
    		if(con)
    		{	
    			var ttt = next(name,id);
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    		return false;
    				
    	}
    	function next(name,id)
    	{
    		location.href= name +".php?id=" + id;
    		return true;
    	}

    i dont want this confirm box when no changes made in form
    Last edited by Dormilich; Mar 20 '10, 03:42 PM. Reason: Please use [code] tags when posting code
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Have a global variable/global flag in default set the value as 0 or 1. Have a listener for all the form data in that page. If any value is changed set the flag to true or 1. When the user clicks on a link. Just check the flag before triggering the confirmation. If the value is true or 1 show the confirmation box or dont show it.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • sarvanhsr
      New Member
      • Jan 2010
      • 8

      #3
      thanks u a lot... i have done that.. its working...

      i used onchange on every elements in my form...

      is there any way to check onchange of whole form using function..

      Again Thank u for kind reply

      Comment

      Working...