PHP / javascript problem

    Date: 03/24/05 (PHP Community)    Keywords: php, browser, java

    Hi all
    I am trying to use a javascript to confirm the deletion of a user in one of my PHP programs. I am using the javascript function confirm(). They way I read it, if the user presses cancel, all action from the form should stop and the browser will remain on the same age. If the user presses ok then the action of the form should be followed out. However whats happening is that no matter which button is pressed the action of the form is carried out. Am I missing something really obvious?

    Here is the javascript :

    	function confirm_delete()
    	{
    		var msg = "Are you sure you want to delete the user?";
    		
    		if (confirm(msg))
    			//window.alert("Delete");
    			location.replace("delete_user.php");
    		else
    			//window.alert("dont delete");
    			location.replace("list_users.php");
    	}
    


    And here is the form line that calls it :

    form method="POST" name="delete_user17" action="delete_user.php" onsubmit="confirm_delete();"
    input type="hidden" name="user_id" value="17"
    

    Source: http://www.livejournal.com/community/php/276608.html

« Arrays and HTML forms || php cgi vs. cli »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home