Return Value from confirmation popup.

Discussion in 'PHP' started by lost, Nov 9, 2005.

  1. #1
    i have a submit button that when selected, will call the function verifySave().
    VerifySave will confirm with a popup.

    echo '<INPUT TYPE=submit VALUE="Save" NAME="generic_savebutton" 
    ONCLICK="verifySave()"/>';
    PHP:
    
    <SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
      function verifySave()
      {
         msg = "Are you sure you want to save this data?";
         return confirm(msg);
      }
    
    
    Code (markup):
    I need to know the syntax on how to check the return value from the verifySave() method. If user selects ok, i need to set a $_SESSION variable.

    Anyone help?
     
    lost, Nov 9, 2005 IP
  2. dataman

    dataman Peon

    Messages:
    94
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not really a PHP question, but here you go!


    // form...

    echo "<input type='hidden' value='0' id='set_this' name='set_this' />";
    echo "<input type='submit' value='Save' name='generic_savebutton' onclick=\"fire('set_this');\" />";
    Code (markup):
    // js

    <script type='text/javascript'>
    <!--//
    	function fire(el)
    	{
    		if ( confirm( 'Are you sure you want to save this data?' ) )
    		{
    			document.getElementById(el).value = 1;
    
    			return ( true );
    		}
    		else
    		{
    			return ( false );
    		}
    	}
    // -->
    </script>
    Code (markup):

    jb
     
    dataman, Nov 9, 2005 IP